Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type –Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll"
- Add-Type –Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
- Function Get-Context([string]$Url,[string]$Username,[string]$Password){
- $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
- $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
- $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
- $ctx.Credentials = $credentials
- return $ctx
- }
- Function Delete-NavigationNode([Microsoft.SharePoint.Client.Web]$Web,[string]$NodeTitle){
- $ctx = $Web.Context
- $nodes = $Web.Navigation.QuickLaunch
- $ctx.Load($nodes)
- $ctx.ExecuteQuery()
- $node = $nodes.GetEnumerator() | where { $_.Title -eq $NodeTitle } | Select -First 1
- $node.DeleteObject()
- $ctx.ExecuteQuery()
- }
- $Url = "https://contoso.sharepoint.com/"
- $Username = "jdoe@contoso.onmicrosoft.com"
- $Password = ""
- $ctx = Get-Context -Url $Url -Username $Username -Password $Password
- Delete-NavigationNode -Web $ctx.Web -NodeTitle "Recent"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement