Created
July 27, 2015 11:26
-
-
Save asadrefai/e2aaddba39e40a42a9be to your computer and use it in GitHub Desktop.
Get Content Organizer Rule Using CSOM PowerShell
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
# replace these details (also consider using Get-Credential to enter password securely as script runs).. | |
$username = "SomeOne@SharePoint.onmicrosoft.com" | |
$password = "YourPassword" | |
$url = "https://YourSite.sharepoint.com" | |
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force | |
# the path here may need to change if you used e.g. C:\Lib.. | |
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" | |
# connect/authenticate to SharePoint Online and get ClientContext object.. | |
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url) | |
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword) | |
$clientContext.Credentials = $credentials | |
if (!$clientContext.ServerObjectIsNull.Value) | |
{ | |
Write-Host "Connected to SharePoint Online site: '$Url'" -ForegroundColor Green | |
$web = $clientContext.Site.RootWeb | |
$listRoutingRules = $web.Lists.GetByTitle("Content Organizer Rules") | |
$item = $listRoutingRules.GetItemById(1) | |
$clientContext.Load($listRoutingRules) | |
$clientContext.Load($item) | |
$clientContext.ExecuteQuery() | |
Write-Host "Title: " $item["Title"] | |
Write-Host "RoutingConditions: " $item["RoutingConditions"] | |
Write-Host "RoutingConditionProperties: " $item["RoutingConditionProperties"] | |
Write-Host "RoutingContentType: " $item["RoutingContentType"] | |
Write-Host "RoutingContentTypeInternal: " $item["RoutingContentTypeInternal"] | |
Write-Host "RoutingConditions: " $item["RoutingConditions"] | |
Write-Host "RoutingConditionProperties: " $item["RoutingConditionProperties"] | |
Write-Host "RoutingAliases: " $item["RoutingAliases"] | |
Write-Host "RoutingTargetLibrary: " $item["RoutingTargetLibrary"] | |
Write-Host "RoutingTargetFolder: " $item["RoutingTargetFolder"] | |
Write-Host "RoutingTargetPath: " $item["RoutingTargetPath"] | |
Write-Host "RoutingAutoFolderProp: " $item["RoutingAutoFolderProp"] | |
Write-Host "RoutingAutoFolderSettings: " $item["RoutingAutoFolderSettings"] | |
Write-Host "RoutingCustomRouter: " $item["RoutingCustomRouter"] | |
Write-Host "RoutingRuleExternal: " $item["RoutingRuleExternal"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment