37 lines
897 B
PowerShell
37 lines
897 B
PowerShell
param(
|
|
[string]$url
|
|
)
|
|
|
|
function Remove-Custom-Action($site, $actionUrl)
|
|
{
|
|
Write-Host "Remove custom action $actionUrl from" $site.Url -foregroundcolor green
|
|
$actions = $site.UserCustomActions
|
|
$contains = $false
|
|
foreach ($a in $actions)
|
|
{
|
|
#Write-Host " " $a.ScriptSrc
|
|
if ($a.ScriptSrc.ToLower().Contains($actionUrl.ToLower()))
|
|
{
|
|
$contains = $true
|
|
$a.Delete()
|
|
Write-Host " Custom action is removed" -foregroundcolor yellow
|
|
return
|
|
}
|
|
}
|
|
|
|
if (!$contains)
|
|
{
|
|
Write-Host " Custom action is not found" -foregroundcolor yellow
|
|
return
|
|
}
|
|
}
|
|
|
|
if (-not $url)
|
|
{
|
|
Write-Host "Specify site url in url parameter" -foregroundcolor red
|
|
return
|
|
}
|
|
|
|
$webApp = Get-SPWebApplication $url
|
|
$webApp.Sites | ForEach-Object { Remove-Custom-Action $_ "CustomAction.js" }
|