How To Access SharePoint Online Site Via PowerShell
posted by Ha Hao
on May 24, 2017
When I worked with SharePoint Online and Window PowerShell, I encountered an issue connecting to SharePoint Online. There are few differences between SharePoint Online and SharePoint On-Premise. This blog will show you the steps to access SharePoint Online.
To get started, since SharePoint Online Management Shell is based on PowerShell 3.0, you need to have it installed. If you are running on Windows 7, it’s necessary to install Windows Management Framework 3.0. But if you are running on Windows 8 – with SharePoint 2013, you’re ready to go.
1. Using SharePoint Online Management Shell
Before you connect to SharePoint Online, you will need to have username and password for an account with global administrator permission. You will also need to know your tenant admin URL (i.e.: https://mytenant-admin.sharepoint.com).
To connect to SharePoint Online, use the Connect-SPOService command. It takes the URL to your tenant admin and a username. As soon as you connect, you’ll be asked for your password.
i.g: Connect-SPOService –Url https://mytenant-admin.sharepoint.com –Credential [email protected]
If you connect successfully, it will return to the command prompt without error. To see what commands are available, you can use Get-Command and pass the module Microsoft.Online.SharePoint.PowerShell.dll.
Get-Command –Module Microsoft.Online.SharePoint.PowerShell
2. Using Window ISE PowerShell
Firstly, before you connect to SharePoint Online Site, you have to make sure that you load the Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime assemblies to your session.
After they are loaded, you can start creating ClientContext and accessing SharePoint Online site with a credential. Please run the following script:
And that’s it – you just accessed SharePoint online site.
Now you can access and do something fun with the $SPOWeb object.
If you find these sites useful, please bookmark this article!
Want more news about Power BI, SharePoint, or Office 365? Subscribe to our newsletter!