Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrwarwick/290f2231fd160ec8cb9b40a0848e3239 to your computer and use it in GitHub Desktop.
Save jrwarwick/290f2231fd160ec8cb9b40a0848e3239 to your computer and use it in GitHub Desktop.
PowerShell preamble to get nuget to get CSOM SDK so as to be able to authenticate to SharePoint Online from script
<# I have had a surprisingly hard time finding successful PowerShell interfaces to SharePoint online.
in lieu of a "pure" powershell replacement for the CSOM client (i.e., an import-module way rather than an SDK installation prerequisite)
I had pretty good luck with this "not so pure" (but still executable inside of same powershell script) preamble.
https://www.microsoft.com/en-us/download/details.aspx?id=42038
https://stackoverflow.com/questions/16657778/install-nuget-via-powershell-script
#>
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = "$rootPath\nuget.exe"
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose
nuget install Microsoft.SharePointOnline.CSOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment