44 lines
1.1 KiB
PowerShell
44 lines
1.1 KiB
PowerShell
param(
|
|
[string]$url
|
|
)
|
|
|
|
function Activate-Feature($site)
|
|
{
|
|
Write-Host "Add custom action on" $site.Url -foregroundcolor green
|
|
$actions = $site.UserCustomActions
|
|
$contains = $false
|
|
foreach ($a in $actions)
|
|
{
|
|
if ($a.ScriptSrc.ToLower() -eq "/_layouts/15/taloyhtio/condoautomation/scripts/taloyhtioresources.js")
|
|
{
|
|
$contains = $true
|
|
break
|
|
}
|
|
}
|
|
|
|
if ($contains)
|
|
{
|
|
Write-Host " Custom action is already added" -foregroundcolor yellow
|
|
return
|
|
}
|
|
|
|
$action = $site.UserCustomActions.Add()
|
|
$action.Location = "ScriptLink"
|
|
$action.ScriptSrc = "/_layouts/15/taloyhtio/condoautomation/scripts/taloyhtioresources.js";
|
|
$action.Sequence = 10001
|
|
#$action.ScriptBlock = null
|
|
$action.Update();
|
|
}
|
|
|
|
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 { Activate-Feature $_ }
|
|
|
|
Stop-Transcript |