74 lines
1.8 KiB
PowerShell
74 lines
1.8 KiB
PowerShell
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$url,
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$oldPmcRelativeUrl,
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$newPmcRelativeUrl
|
|
)
|
|
|
|
function Write-File($msg)
|
|
{
|
|
($msg) | Out-File "log-page-layouts.txt" -Append
|
|
}
|
|
|
|
function Write-Info($msg)
|
|
{
|
|
Write-Host $msg -foregroundcolor green
|
|
Write-File $msg
|
|
}
|
|
|
|
function Write-Warn($msg)
|
|
{
|
|
Write-Host $msg -foregroundcolor yellow
|
|
Write-File $msg
|
|
}
|
|
|
|
function Get-List($web, $listTitle)
|
|
{
|
|
$list = $null
|
|
foreach ($l in $web.Lists)
|
|
{
|
|
#Write-Info ("List '" + $l.Title + "'")
|
|
#Write-Info ($listTitle)
|
|
if ($l.Title.ToLower() -eq $listTitle.ToLower())
|
|
{
|
|
$list = $l
|
|
break
|
|
}
|
|
}
|
|
return $list
|
|
}
|
|
|
|
function Fix-Lisapalvelut-Web($web, $oldPmcRelativeUrl, $newPmcRelativeUrl)
|
|
{
|
|
Write-Info ("Fix Lisapalvelut for web: " + $web.Url)
|
|
$list = Get-List $web "Lisäpalvelut"
|
|
foreach ($item in $list.Items)
|
|
{
|
|
if ($item["Url"].ToString().ToLower().Contains("/" + $oldPmcRelativeUrl.ToLower() + "/"))
|
|
{
|
|
Write-Info (" Fix " + $item["Url"])
|
|
$item["Url"] = $item["Url"].ToString().ToLower().Replace("/" + $oldPmcRelativeUrl.ToLower() + "/", "/" + $newPmcRelativeUrl.ToLower() + "/")
|
|
$item.Update()
|
|
}
|
|
}
|
|
|
|
foreach ($subWeb in $web.Webs)
|
|
{
|
|
Fix-Lisapalvelut-Web $subWeb $oldPmcRelativeUrl $newPmcRelativeUrl
|
|
}
|
|
}
|
|
|
|
function Fix-Lisapalvelut-Site($site, $oldPmcRelativeUrl, $newPmcRelativeUrl)
|
|
{
|
|
foreach ($web in $site.RootWeb.Webs)
|
|
{
|
|
Fix-Lisapalvelut-Web $web $oldPmcRelativeUrl $newPmcRelativeUrl
|
|
}
|
|
}
|
|
|
|
$site = Get-SPSite $url
|
|
Fix-Lisapalvelut-Site $site $oldPmcRelativeUrl $newPmcRelativeUrl
|
|
#$web = Get-SPWeb $url
|
|
#Fix-Lisapalvelut-Web $web $oldPmcRelativeUrl $newPmcRelativeUrl |