Created
April 18, 2017 20:18
-
-
Save star-crossed/ed78de21cf529219f4dd78f6462ca0d0 to your computer and use it in GitHub Desktop.
PowerShell script for SharePoint using CSOM to take a list column and "promote" it to a site column.
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
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true, HelpMessage="This is the URL to the SharePoint Online site.")] | |
[string]$Url, | |
[Parameter(Mandatory=$false, HelpMessage="This is the path to the DLLs for CSOM.")] | |
[string]$CSOMPath | |
) | |
Set-Strictmode -Version 1 | |
If ($CSOMPath -eq $null -or $CSOMPath -eq "") { $CSOMPath = "." } | |
Add-Type -Path "$CSOMPath\Microsoft.SharePoint.Client.dll" | |
Add-Type -Path "$CSOMPath\Microsoft.SharePoint.Client.Runtime.dll" | |
$psCredentials = Get-Credential | |
$spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($psCredentials.UserName, $psCredentials.Password) | |
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($Url) | |
$clientContext.Credentials = $spoCredentials | |
$domain = ([System.Uri]$Url).Host | |
$userName = $psCredentials.UserName | |
If ($clientContext.ServerObjectIsNull.Value) { | |
Write-Error "Could not connect to SharePoint Online site collection: $Url" | |
} Else { | |
Write-Host "Connected to SharePoint Online site collection: " $Url -ForegroundColor Green | |
$web = $clientContext.Web | |
$clientContext.Load($web) | |
$clientContext.Load($web.SiteGroups) | |
$clientContext.ExecuteQuery() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment