Download and Install SharePoint Online Client Components SDK using PowerShell
What is SharePoint Online client components SDK?
The SharePoint Online Client Components SDK provides the tools necessary to develop applications that interact with SharePoint Online. It includes libraries for accessing SharePoint data and functionality and extensive documentation on how to use these libraries. We need SharePoint Online client components SDK installed on the client machine to be able to connect and work with SharePoint Online objects programmatically from the client-side using PowerShell. The SDK includes libraries for working with sites, lists, items, files, etc.
Download and Install the SharePoint Online client components SDK
To use the SharePoint Online Client Components SDK, you must first download and install it on your development machine. In this tutorial, we will guide you through the process of downloading and installing the SharePoint Online Client Components SDK, step by step.
We can download the latest SharePoint Online client components SDK from the Official Microsoft download center at https://www.microsoft.com/en-us/download/details.aspx?id=42038,
This installs CSOM assemblies (DLL files – Such as: Microsoft.SharePoint.Client.dll, Microsoft.SharePoint.Client.Runtime.dll, etc.) at folder “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI”
Connect to SharePoint Online CSOM from PowerShell
Once installed, you can reference them in your PowerShell scripts as:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Get Credentials to connect
$Cred= Get-Credential
$SiteURL = "https://crescent.sharepoint.com"
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get The Web
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Get Web Title
Write-host $Ctx.Web.Title
Download and Install SharePoint Online Client Components SDK using PowerShell
SharePoint Online Client Components SDK is a set of client-side libraries that allows developers to access and interact with SharePoint Online data from their custom solutions. How about downloading and installing CSOM assemblies using PowerShell? Here is the PowerShell to install SharePoint online client components SDK:
#Parameters
$DownloadURL = "https://download.microsoft.com/download/B/3/D/B3DA6839-B852-41B3-A9DF-0AFA926242F2/sharepointclientcomponents_16-6906-1200_x64-en-us.msi"
$Assemblies= @(
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll",
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
)
#Check if all assemblies given in the list are found
$FileExist = $True
ForEach ($File in $Assemblies)
{
#Check if CSOM Assemblies are Found
If(!(Test-Path $File))
{
$FileExist = $False; Break;
}
}
#Download and Install CSOM Assemblies
If(!$FileExist)
{
#Download the SharePoint Online Client SDK
Write-host "Downloading SharePoint Online Client SDK..." -f Yellow -NoNewline
$InstallerPath = "$Env:TEMP\SharePointOnlineClientComponents16.msi"
Invoke-WebRequest $DownloadURL -OutFile $InstallerPath
Write-host "Done!" -f Green
#Start Installation
Write-host "Installing SharePoint Online Client SDK..." -f Yellow -NoNewline
Start-Process MSIExec.exe -ArgumentList "/i $InstallerPath /qb" -Wait
Write-host "Done!" -f Green
}
Else
{
Write-host "SharePoint Online CSOM assemblies are already installed!" -f Yellow
}
If you want to uninstall SharePoint online client components SDK, use “Add or Remove Programs” under the control panel!
In summary, SharePoint Online Client Components SDK is a critical component for developers who want to build custom solutions for SharePoint Online. The SDK provides access to the underlying data and functionality of SharePoint Online. Downloading and installing the SharePoint Online Client Components SDK is a straightforward process that can be accomplished in a few simple steps. With the SDK installed on your development machine, you will be able to start building custom solutions for SharePoint Online and take advantage of the full power and flexibility of the platform.
Thanks for sharing. It helped me a great deal!
I installed this and it disabled my ability to use sharepoint online cmdlets. Uninstalling the components brought them back. Sounds like a GAC conflict. Any hints?
Yes! Module-based installation is preferred to avoid such conflicts. How to Install SharePoint Online PowerShell Module?