2

Is it possible to use the SharePoint Online cmdlets (Get-SPOsite, etc) in normal PowerShell and not through the SharePoint Online Management Shell (SPOMS)? From what I can tell the SPOMS is just normal PowerShell with -Command "Import-Module Microsoft.Online.SharePoint.PowerShell" run as a parameter when launched.

Is there a way I can manually import a library at the top of my powershell scripts so that they would run on a PowerShell client that hasn't the SPOMS already installed?

If so, what DLLs do I need to import for the Get-SPOSite cmdlets to become available?

2

If you don't want to use the SharePoint Online Management Shell, I don't, you can create a profile, to help out.

new-item -path $profile -itemtype file -force
notepad $profile

Edit the profile to include the path to the SPO modules, as well as the SharePoint Online Client Components.

#Bring in the Sharepoint modules
Import-Module "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell" -DisableNameChecking

#Add references to SharePoint client assemblies - required for CSOM
Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"
Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.Office.Client.Policy.dll"
Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Publishing.dll"
Import-Module "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"

Restart Powershell and you'll be good. If you work in both the ISE and regular powershell, you'll need to do this for both applications.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.