param( [Parameter(Mandatory=$true)] [string]$url ) function Write-Log($msg) { Write-Host $msg -foregroundcolor green ($msg) | Out-File "log-update-filenotfound.txt" -Append } function Update-FileNotFound($site) { if ($site.ID -eq $site.WebApplication.Sites[0].ID -or $site.Url -eq "http://intra.jarjestotalo.fi") { $expectedUrl = "/_layouts/15/Taloyhtio/Common/PageNotFound.aspx" } else { $expectedUrl = $site.ServerRelativeUrl + "/_layouts/15/Taloyhtio/Common/PageNotFound.aspx" } Write-Log ("Update page not found url for '" + $site.Url + "' to " + $expectedUrl) $site.FileNotFoundUrl = $expectedUrl } $site = Get-SPSite $url Update-FileNotFound $site