Download and Install SharePoint Online Client Components SDK using PowerShell
We need SharePoint Online client components SDK installed on the client machine, to be able to connect and work with SharePoint Online objects programmatically. We can download and install CSOM assemblies for SharePoint Online from https://www.microsoft.com/en-us/download/details.aspx?id=42038,
This installs a couple of assemblies (DLL files!) at folder "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI"
Once installed, you can reference them in your PowerShell scripts as:
Download and Install SharePoint Online Client Components SDK using PowerShell
How about downloading and installing CSOM assemblies using PowerShell?
This installs a couple of assemblies (DLL files!) at folder "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI"
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
How about downloading and installing CSOM assemblies using PowerShell?
#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 }
No comments:
Please Login and comment to get your questions answered!