PowerShell kullanarak SharePoint'teki Özel Eylem Nasıl Kaldırılır?
Gereksinim: PowerShell'i kullanarak SharePoint'teki bir Özel Eylemi kaldırın.
SharePoint'te PowerShell kullanarak Özel Eylemi Silme
PowerShell kullanarak SharePoint 2013'teki özel eylemi şu şekilde kaldırabilirsiniz:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Set Site variable
$SiteURL="https://intranet.crescent.com"
$CustomActionTitle ="Support Center"
Try {
#Get the Web
$Web = Get-SPWeb $SiteURL
#Get the Custom Actions Filter by Title
$CustomActions = $web.UserCustomActions | Where { $_.Title -eq $CustomActionTitle } | Select ID, Title
If($CustomActions -ne $Null)
{
#Delete custom action(s)
$CustomActions | ForEach-Object {
#Remove the custom action
$web.UserCustomActions.Item($_.Id).Delete()
Write-Host -f Green "Custom Action '$($_.Title)' Deleted Successfully!"
}
}
Else
{
write-host -f Yellow "Custom Action '$CustomActionTitle' Doesn't Exist!"
}
} Catch {
Write-Host -ForegroundColor Red "Error:" $_.Exception.Message
}
Verilen kapsamdaki tüm özel eylemleri silmek için “Nerede” sınıfını komut dosyasından kaldırmanız yeterlidir!
Bunu yeniden kullanılabilir bir fonksiyon haline getirelim:
Function Remove-CustomAction
{
param
(
[parameter(Mandatory=$true, ParameterSetName='Site')]
[Microsoft.SharePoint.SPSite]$Site,
[parameter(Mandatory=$true, ParameterSetName='Web')]
[Microsoft.SharePoint.SPWeb]$Web,
[parameter(Mandatory=$true, ParameterSetName='Site')]
[parameter(Mandatory=$true, ParameterSetName='Web')]
[string]$ActionName
)
begin
{
$existingActions = @()
}
process
{
if( $PSCmdlet.ParameterSetName -eq "Site" )
{
$Site.UserCustomActions | ? { $_.Title -eq $ActionName } | % { $existingActions += $_ }
$existingActions | % { $Site.UserCustomActions.Item($_.Id).Delete() }
}
else
{
$Web.UserCustomActions | ? { $_.Title -eq $ActionName } | % { $existingActions += $_ }
$existingActions
$existingActions | % { $Web.UserCustomActions.Item($_.Id).Delete() }
}
}
end
{
}
}
#Call the function
Remove-CustomAction -Site $site -ActionName "SiteBanner"
SharePoint Online'da özel eylemi silmeyle ilgili yayınım: PowerShell kullanarak SharePoint Online'da Özel Eylem Nasıl Silinir?