Wednesday, 18 December 2013

Managing SharePoint Online with Powershell


Set up the SharePoint Online Management Shell environment for SharePoint Online global administrators

Steps to follow:

  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 admin@contoso.com, 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
To establish a connection to your SharePoint Online tenant you will need to use the
 Connect-SPOService cmdlet (Remember that you must use the tenant admin site url as a parameter).

 This will fill up a static internal variable which will be used afterwards. You should clear this internal variable using the Disconnect-SPOService cmdlet.
    Connect-SPOService –Url https://yoursite-admin.sharepoint.com –credential prasanna@yoursite.onmicrosoft.com

Once you are connected you can manipulate your SharePoint Online environment. There are only 30 cmdlets available in for SharePoint Online – to get a full list type the following command. 
Get-Command –Module Microsoft.Online.SharePoint.PowerShell

All cmdlets start with SPO. Most cmdlets are related to site collection management, user and app management. All returned object are simple data objects and most of them are limited in functionality.  


Cmdlet name

                Description

Add-SPOUser

Adds an existing Office 365 user or an Office 365 security group to a SharePoint group.

Connect-SPOService

Connects a SharePoint Online global administrator to a SharePoint Online connection (the SharePoint Online Administration Center). This cmdlet must be run before any other SharePoint Online cmdlets can run.

Disconnect-SPOService

Disconnects from a SharePoint Online service.

Get-SPOAppErrors

Returns application errors.

Get-SPOAppInfo

Returns all installed applications.

Get-SPODeletedSite

Returns all deleted site collections that are in the Recycle Bin.

Get-SPOSite

Returns one or more site collections.

Get-SPOSiteGroup

Returns all the groups on the specified site collection.

Get-SPOTenantLogEntry

Retrieves SharePoint Online company logs.

Get-SPOTenantLogLastAvailableTimeInUtc

Returns the time when the SharePoint Online organization logs are collected.

Get-SPOUser

Returns the SharePoint Online user or security group accounts that match given search criteria.

Get-SPOWebTemplate

Shows all site templates that match the given identity.

New-SPOSite

Creates a new SharePoint Online site collection for the current company.

New-SPOSiteGroup

Creates a new group in a SharePoint Online site collection.

Remove-SPODeletedSite

Removes a SharePoint Online deleted site collection from the Recycle Bin.

Remove-SPOSite

Sends a SharePoint Online site collection to the SharePoint Online Recycle Bin.

Remove-SPOSiteGroup

Removes a SharePoint Online group from a site collection.

Remove-SPOUser

Removes a user or a security group from a site collection or a group.

Repair-SPOSite

Checks and repairs the specified site collection and its contents.

Request-SPOUpgradeEvaluationSite

Requests to create a copy of an existing site collection for the purposes of validating the effects of upgrade without affecting the original site.

Restore-SPODeletedSite

Restores a SharePoint Online deleted site collection from the Recycle Bin.

Set-SPOSite

Sets or updates the values of one or more properties for a site collection.

Set-SPOSiteGroup

Updates the SharePoint Online owner and permission level on a group inside a site collection.

Set-SPOTenant

Sets properties on the SharePoint Online organization.

Set-SPOUser

Configures properties on an existing user.

Test-SPOSite

Tests a SharePoint Online site collection.

Upgrade-SPOSite

Starts the upgrade process on a site collection.
Here you can check on microsoft site:

There's a list of the online compatible cmdlets here: http://technet.microsoft.com/en-us/library/fp161364.aspx
Also here's the process to start using PowerShell with Office 365: http://technet.microsoft.com/en-us/library/fp161372.aspx

There are no cmdlets available for managing SharePoint objects at a lower scope than the site collection. The following examples show you some examples of the more common cmdlets. To see a list of site collections associated with a subscription or to see the details for a specific site collection use the Get-SPOSite cmdlet. Use the following command to retrieve the details about a specific SharePoint Online site collection. You need to specify the –Detailed option to retrieve information about CompatibilityLevel,ResourceUsageCurrent,ResourceUsageAverage, StorageUsageCurrent,Webcount and the Title. 
Get-SPOSite https://yoursite.sharepoint.com –Detailed | select *
A slight variation on the script above allows you to get usage data about all of your different SharePoint Online site collections. The use of –limit all allows you to get all of the SP Online site collection, standard it will only return 200. 
Get-SPOSite –limit all –detailed | Export-CSV –path MyReport.csv

1 comment: