SharePoint Online: Egyéni művelet eltávolítása a PowerShell CSOM segítségével
Követelmény: Töröljön egy egyéni műveletet a SharePoint Online-ban a PowerShell segítségével.
SharePoint Online: PowerShell az egyéni művelet eltávolításához
Itt található a PowerShell CSOM-szkript az egyéni művelet eltávolításához:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Set parameter values
$SiteURL="https://Crescent.sharepoint.com/"
$CustomActionTitle = "SharePoint Admin Center"
Try{
#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get All Custom Actions
$Web = $Ctx.Web
$UserCustomActions= $Web.UserCustomActions
$Ctx.Load($UserCustomActions)
$Ctx.ExecuteQuery()
#Get Custom Action(s) to delete
$CustomActions = $UserCustomActions | Where { $_.Title -eq $CustomActionTitle }
If($CustomActions -ne $Null)
{
#Delete all custom actions
$CustomActions | ForEach-Object {
#Remove the custom action
$_.DeleteObject()
Write-Host -f Green "Custom Action '$($_.Name)' Deleted Successfully!"
}
$Ctx.ExecuteQuery()
}
Else
{
write-host -f Yellow "Custom Action Does not Exist!"
}
}
Catch {
write-host -f Red "Error Removing Custom Action!" $_.Exception.Message
}
Ezzel törli az összes, a megadott címmel rendelkező egyéni műveletet. Ezeket a nevük, azonosítójuk vagy egyéb paramétereik segítségével is megszerezheti és törölheti.
PnP PowerShell egyéni művelet törléséhez a SharePoint Online-ban
Használja a Remove-PnPCustomAction PnP parancsmagot egy egyéni művelet eltávolításához a SharePoint Online-ban.
#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Retail"
#Connect to SharePoint Online Site
Connect-PnPOnline -Url $SiteURL -Interactive
#Get Custom Actions
Get-PnPCustomAction
#Remove Custom Action
Remove-PnPCustomAction -Identity "SharePoint Admin Center" -Force