Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu :: How to Connect SharePoint Online Using PowerShell?
PowerShell is a powerful Command Line Shell Script mainly used by the administrators, and manages anything in Microsoft products. Each Microsoft product, be it Excel, SQL, Office applications, or SharePoint, has its own set of cmdlets [commands used to run any operation that can be performed using GUI and more than it].
Check the cmdlets that can be used in the SharePoint on-premises in my previous article.
But working with SharePoint online is a bit different. The prerequisites are –
PowerShell v3
.NET Framework
SharePoint Module – which can be downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=35588
Once the module is downloaded, open SharePoint Online Management Shell and run the cmdlet to import the SharePoint online module cmdlets.
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking;
Or the SharePoint Online Management Shell can be installed directly using the link – https://www.microsoft.com/en-in/download/details.aspx?id=35588
Connect-SPOService -Url https://xyz.sharepoint.com -Credential peter@hostforlife.eu
Note
The connecting site should be a tenant administrator site and the user should have tenant administrator access. The session will be active as an internal variable.
To clear out the service, run Disconnect-SPOService cmdlet which will clear the connected session.
For code reusability, it is better to create a function to connect with SharePoint Online adminstrator site.
1 2 3 4 5 6 7 8 9 10 11 |
function ConnectSPOnlineSite() { param ( $admin = "peter@hostforlife.eu", $adminSite = "https://xyz.sharepoint.com" ) if ((Get-Module Microsoft.Online.SharePoint.PowerShell).Count -eq 0) { Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking } $cred = Get-Credential $admin Connect-SPOService -Url $adminSite -Credential $cred } |
There is a small change in the cmdlets of SharePoint On-premises and SharePoint Online. In “noun-verb” part of PowerShell cmdlets, the verb has prefixed Get-SPO****.
Example
Get-SPOSite- gets the site collection of particular URL/identity,
Get-SPOSiteGroup- returns all site groups of one or more site collection,
Get-SPOTenant – gets SharePoint online organization properties.
Most of the cmdlets are available till site collection level not till the site level [SPweb level as compared to SharePoint on premises ].
Print article | This entry was posted by Peter on August 10, 2017 at 7:36 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |