SHARE
TWEET

Untitled

a guest Jun 29th, 2018 200 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $User = "admin@tenant.onmicrosoft.com"
  2. $Site = "https://tenant.sharepoint.com/sites/home"
  3. $GroupName = "Group"
  4. $TermSetName = "Term Set"
  5.  
  6. #Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
  7. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll"
  8. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  9. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Taxonomy.dll"
  10. $Password = Read-Host -Prompt "Please enter your password" -AsSecureString
  11.  
  12. # Bind to MMS
  13. $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
  14. $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
  15. $Context.Credentials = $Creds
  16. $MMS = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($Context)
  17. $Context.Load($MMS)
  18. $Context.ExecuteQuery()
  19.    
  20. $User = "admin@tenant.onmicrosoft.com"
  21. $Site = "https://tenant.sharepoint.com/sites/home"
  22. $GroupName = "Group"
  23. $TermSetName = "Term Set"
  24.  
  25. #Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
  26. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll"
  27. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  28. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Taxonomy.dll"
  29. $Password = Read-Host -Prompt "Please enter your password" -AsSecureString
  30.  
  31. $spContext = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
  32. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
  33. $spContext.Credentials = $credentials
  34.  
  35. $web = $spContext.Web
  36. $site = $spContext.Site
  37. $spContext.Load($web)
  38. $spContext.Load($site)
  39. $spContext.ExecuteQuery()
  40.  
  41. $MMS = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($spContext)
  42. $Context.Load($MMS)
  43. $Context.ExecuteQuery()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top