Advertisement
Guest User

Untitled

a guest
Apr 19th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. Add-Type –Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll"
  2. Add-Type –Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  3.  
  4.  
  5. Function Get-Context([string]$Url,[string]$Username,[string]$Password){
  6. $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
  7. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
  8. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
  9. $ctx.Credentials = $credentials
  10. return $ctx
  11. }
  12.  
  13.  
  14. Function Delete-NavigationNode([Microsoft.SharePoint.Client.Web]$Web,[string]$NodeTitle){
  15. $ctx = $Web.Context
  16. $nodes = $Web.Navigation.QuickLaunch
  17. $ctx.Load($nodes)
  18. $ctx.ExecuteQuery()
  19.  
  20. $node = $nodes.GetEnumerator() | where { $_.Title -eq $NodeTitle } | Select -First 1
  21. $node.DeleteObject()
  22. $ctx.ExecuteQuery()
  23. }
  24.  
  25.  
  26.  
  27. $Url = "https://contoso.sharepoint.com/"
  28. $Username = "jdoe@contoso.onmicrosoft.com"
  29. $Password = ""
  30.  
  31.  
  32. $ctx = Get-Context -Url $Url -Username $Username -Password $Password
  33. Delete-NavigationNode -Web $ctx.Web -NodeTitle "Recent"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement