Created
April 4, 2016 08:27
-
-
Save aaira-a/be728722b623c9382086992a22511cf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM | |
Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll” | |
Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll” | |
Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll” | |
#Specify tenant admin and site URL | |
$SiteUrl = "mysiteurl" | |
$UserName = "myusername" | |
$SecurePassword = ConvertTo-SecureString "mypassword" -AsPlainText -Force | |
#Bind to site collection | |
$ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) | |
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword) | |
$ClientContext.Credentials = $Credentials | |
$ClientContext.ExecuteQuery() | |
# Get WorkflowServicesManager | |
$WorkflowServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($ClientContext, $ClientContext.Web) | |
$ClientContext.Load($WorkflowServicesManager) | |
$ClientContext.ExecuteQuery() | |
# Get Site and Web Id | |
$ClientContext.Load($ClientContext.Web) | |
$ClientContext.Load($ClientContext.Site) | |
$ClientContext.ExecuteQuery() | |
$ClientContext.Web.Id | |
$ClientContext.Site.Id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment