Sharepoint - How to connect to SharePoint online to run some PowerShell

Connecting to SharePoint Online

Before you connect to SharePoint Online, you’ll need to have the username and password for an account with global administrator permissions. You’ll also need to know your tenant admin URL (i.e.: https://mytenant-admin.sharepoint.com). When connecting to SharePoint Online, don’t forget to reference all URLs securely using https.If you try and use http, you will get an error. To connect to SharePoint Online, use the Connect-SPOService command. It takes the URL to your tenant admin and a username. When you connect, you’ll be prompted for your password.

Connect-SPOService –Url https://mytenant-admin.sharepoint.com –Credential [email protected]

SPO Management Shell

If you connect successfully, you will be returned to the command prompt without error. To see what commands are available, we can use Get-Command and pass it the module Microsoft.Online.SharePoint.PowerShell.dll

Source: https://web.archive.org/web/20190301143657/http://dotnet.sys-con.com/node/2465770


Please refer to these two links from MSDN; they show everything you need to know about SharePoint Online and PowerShell.

http://technet.microsoft.com/en-us/library/fp161362(v=office.15)

and to your issue of how to setup PowerShell for SharePoint Online:

  1. Install Windows PowerShell 3.0 from Windows Management Framework 3.0.

  2. Install the SharePoint Online Management Shell from the Microsoft Download Center.

  3. Click Start>All Programs>SharePoint Online Management Shell.

  4. Run Connect-SPOService. For example, Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential [email protected], where:
    • Url is the URL of the SharePoint Online Administration Center.

    • Credential is the user name to which you want to grant access to the SharePoint Online Administration Center site.

  5. Try it out! For example, run Get-SPOSite to get a list of all sites.

http://technet.microsoft.com/en-us/library/fp161372