param( [string]$url ) function Rename-Field($site) { Write-Host "Rename field on" $site.Url -foregroundcolor green $u = [Microsoft.SharePoint.Utilities.SPUrlUtility]::CombineUrl($site.Url, "lomakkeet") $web = Get-SPWeb $u -ErrorAction SilentlyContinue if ($web -eq $null) { Write-Host " Web $u not found" -foregroundcolor yellow return } $list = $null foreach($l in $web.Lists) { if ($l.Title.ToLower() -eq "vikailmoitukset") { $list = $l break } } if ($list -eq $null) { Write-Host " List not found" -foregroundcolor yellow return } $ct = $null foreach ($c in $list.ContentTypes) { if ($c.Name.ToLower() -eq "lomake") { $ct = $c break } } if ($ct -eq $null) { Write-Host " Content type not found" -foregroundcolor yellow return } $fl = $null foreach ($f in $list.Fields) { if ($f.Title.ToLower() -eq "asunto") { $fl = $f break } } if ($fl -eq $null) { Write-Host " Field not found" -foregroundcolor yellow return } $lcid = [int]$web.Language $ci = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList $lcid [System.Threading.Thread]::CurrentThread.CurrentCulture = $ci [System.Threading.Thread]::CurrentThread.CurrentUICulture = $ci $fl.Title = "Huoneisto" $fl.Update() Write-Host " Field was successfully renamed" -foregroundcolor green } Start-Transcript -Path "output.log" -Append -Force -Confirm:$false if (-not $url) { Write-Host "Specify site url in url parameter" -foregroundcolor red return } $webApp = Get-SPWebApplication $url $webApp.Sites | ForEach-Object { Rename-Field $_ } #$s = Get-SPSite "http://taloyhtio.mobimus.com/demo4" #Rename-Field $s Stop-Transcript