54 lines
1.2 KiB
PowerShell
54 lines
1.2 KiB
PowerShell
param(
|
|
[string]$url
|
|
)
|
|
|
|
function Add-Custom-Action($site, $actionUrl, $sequence)
|
|
{
|
|
Write-Host "Add custom action $actionUrl on" $site.Url -foregroundcolor green
|
|
$actions = $site.UserCustomActions
|
|
$contains = $false
|
|
foreach ($a in $actions)
|
|
{
|
|
#Write-Host " " $a.ScriptSrc
|
|
if ($a.ScriptSrc.ToLower() -eq $actionUrl.ToLower())
|
|
{
|
|
$contains = $true
|
|
#$a.Delete()
|
|
break
|
|
}
|
|
}
|
|
|
|
if ($contains)
|
|
{
|
|
Write-Host " Custom action is already added" -foregroundcolor yellow
|
|
return
|
|
}
|
|
|
|
$action = $site.UserCustomActions.Add()
|
|
$action.Location = "ScriptLink"
|
|
$action.ScriptSrc = $actionUrl
|
|
$action.Sequence = $sequence
|
|
$action.Update();
|
|
}
|
|
|
|
function Add-Form-Filling($site)
|
|
{
|
|
Add-Custom-Action $site "/_layouts/15/taloyhtio/scripts/InitForm.js?v=20200828" 10003
|
|
}
|
|
|
|
#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 { Add-Form-Filling $_ }
|
|
|
|
|
|
#$site = Get-SPSite $url
|
|
#Add-Form-Filling $site
|
|
|
|
#Stop-Transcript |