Thursday, 28 February 2013

Windows PowerShell for SharePoint Online Reference - Part 2

You can find part 1 of this blog here:

Organization level monitoring and management


Get-SPOAppErrors 
Use this command to get application errors.
Example:
Get-SPOAppErrors –ProductId ba51729b-e017-409d-681a-66f1dd18f0f4

Get-SPOAppInfo 
This command will return a list of all installed applications.
Example:
Get-SPOAppInfo –Name "Excel Service" 

Get-SPOTenant 
Returns SharePoint Online organization properties.
Example:
Get-SPOTenant


Get-SPOTenantLogEntry 
Retrieves SharePoint Online company logs. For now, the only logs available are for Business Connectivity Services (BCS).
Example:
$endtime = Get-SPOTenantLogLastAvailableTimeInUtc$starttime = $endTimeinUTC.AddMinutes(-1200000)$tenantlogs = Get-SPOTenantLogEntry -StartTimeinUtc $startTimeinUTC.Date -EndTimeinUTC $endTimeinUTC.Date

Get-SPOTenantLogLastAvailableTimeInUtc 
This command returns the time when the SharePoint Online organization logs are collected. Same as the Get-SPOTenantLogEntry command, for now, the only logs available are for Business Connectivity Services (BCS).
Example:
Get-SPOTenantLogLastAvailableTimeInUtc


Get-SPOWebTemplate
You can use this command to get a list of all site templates available that match a given identity.
Example:
Get-SPOWebTemplate

Set-SPOTenant
This command sets properties on the SharePoint Online organization.
Example:
Set-SPOSite -Identity https://adoptcloud.sharepoint.com/sites/coolsite -LockState NoAccess

Upgrade


Upgrade-SPOSite 
After your Wave 14 Office 365 tenant is upgraded to Wave 15, you will notice that your SharePoint sites are not automatically upgraded to the latest SharePoint 2013 site. You can use this command to trigger the upgrade after you have properly assessed and tested the impacts of upgrade.
Example:
Upgrade-SPOSite -Identity https://adoptcloud.sharepoint.com/sites/coolsite

and here is a reference to available parameters for this command:
http://technet.microsoft.com/en-us/library/fp161395.aspx



Request-SPOUpgradeEvaluationSite
As mentioned in Upgrade-SPO command, before upgrading to SharePoint 2013 in Office 365, you may want to test the impacts of the upgrade in advance. you use this command request to create a copy of an existing site collection for the purposes of validating the effects of upgrade without affecting the original site.
Example:
Request-SPOUpgradeEvaluationSite http://adoptcloud.sharepoint.com/sites/coolsite

Reference for more reading:
http://technet.microsoft.com/en-us/library/fp161386.aspx

Windows PowerShell for SharePoint Online Reference - Part 1

You can now use SharePoint Online Management Shell to performs administration tasks on SharePoint Online. In this article I have put together a reference to all the commands available to date for SharePoint Online with examples.

You can also use the "Windows PowerShell for SharePoint Command Builder" tool to build commands using a drag and drop interface which allows you to select and enter command parameters in a visual way. Refer to this post for more information about this tool.

Service connection and disconnection


Connect-SPOService 
This command is used to establish a connection to SharePoint Online Administration Center.
Examples:
Connect-SPOService -Url https://adoptcloud-admin.sharepoint.com -credential amin.tavakoli@adoupcloud.com


Disconnect-SPOService 
Use this to disconnect from SharePoint Online.
Examples:
Disconnect-SPOService


User management


Add-SPOUser
This coman is used to add an existing Office 365 user or an Office 365 security group to a SharePoint group.
Examples:
Add-SPOUser -Site https://adoptcloud.sharepoint.com/sites/marketing -LoginName amin.tavakoli@adoptcloud.com -Group "Marketing Owners"


Get-SPOUser 
This command is used to return the SharePoint Online user or security group accounts that match a given search criteria.
Examples:
Get-SPOUser -Site https://adoptcloud.sharepoint.com/sites/marketing -Group "Team Site Members"
or
Get-SPOUser -Site https://adoptcloud.sharepoint.com/sites/marketing -LoginName amin.tavakoli@adoptcloud.com

Remove-SPOUser 
Use this command to remove a user or a security group from a site collection or a group.
Examples:
Remove-SPOUser -Site https://adoptcloud.sharepoint.com/sites/marketing -LoginName amin.tavakoli@adoupcloud.com -Group "Marketing Owners"

Set-SPOUser 
This can be used to configure properties of an existing user
Examples:
Set-SPOUser -Site https://adoptcloud.sharepoint.com/sites/marketing -LoginName amin.tavakoli@adoupcloud.com -IsSiteCollectionAdmin $true 

User group management

Get-SPOSiteGroup
Use this command to get a list of all the groups on the specified site collection.
Examples:
Get-SPOSiteGroup -Site http://adoptcloud.sharepoint.com/sites/marketing


New-SPOSiteGroup
This command can be used to create a new group in a SharePoint Online site collection.
Examples:
New-SPOSiteGroup -Site https://adoptcloud.sharepoint.com/sites/marketing -Group "Senior Marketing Staff" -PermissionLevels "Design"


Remove-SPOSiteGroup 
Use this to remove a SharePoint Online group from a site collection.
Examples:
Remove-SPOSiteGroup -Site https://adoptcloud.sharepoint.com/sites/marketing -Identity "MarketingManagers"


Set-SPOSiteGroup
This command updates the SharePoint Online owner and permission levels on a group inside a site collection.
Examples:
Set-SPOSiteGroup -Site https://adoptcloud.sharepoint.com -Identity "CoolGroup" -Owner amin.tavakoli@adoupcloud.com

Site collection management

Get-SPODeletedSite 
Use this to get a list of deleted SharePoint sites in the Recycle Bin.
Examples:
Get-SPODeletedSite -Identity http://adoptcloud.sharepoint.com/sites/UncoolSite

Get-SPOSite
This command returns one or more site collections
Get-SPOSite -Identity https://adoptcloud.sharepoint.com


New-SPOSite
Use this to create a site collection.
Examples:
New-SPOSite -Url http://adoptcloud.sharepoint.com/sites/CoolSite -Owner amin.tavakoli@adoupcloud.com -StorageQuota 1500 -CompatibilityLevel 15 -LocaleID 1033 -ResourceQuota 300 -Template "mytemplatename" -TimeZoneId 13 -Title "This is my new so cool site"


Remove-SPODeletedSite
Use this command to get rid of the sites in the Recycle Bin.
Examples:
Remove-SPODeletedSite -Identity https://adoptcloud.sharepoint.com/sites/IHateThisSite

Remove-SPOSite
Use this to delete a site. After deletion site will remain in Recycle Bin.
Examples:
Remove-SPOSite -Identity https://adoptcloud.sharepoint.com/sites/uncoolsite -NoWait

Repair-SPOSite
This command can be used to checks and repair a site collection and its contents.
Examples:
Repair-SPOSite https://adoptcloud.sharepoint.com/sites/damagedcoolsite

Restore-SPODeletedSite 
Use this command to restore a deleted site collection from the Recycle Bin.
Examples:
Restore-SPODeletedSite -Identity https://adoptcloud.sharepoint.com/sites/myrecycledsite

Set-SPOSite
Use this to set or update one or more properties for a site collection.
Examples:
Set-SPOSite -Identity https://adoptcloud.sharepoint.com -StorageQuota 3000 -StorageQuotaWarningLevel 2000


Test-SPOSite 
Use this command to test a  site collection.
Examples:
Test-SPOSite https://adoptcloud.sharepoint.com/sites/coolsite

Windows PowerShell Command Builder


The Windows PowerShell Command Builder for Microsoft SharePoint 2010, Microsoft SharePoint 2013, SharePoint Online, and Microsoft Office 365 is an HTML5 application that is designed to help IT professionals and power users learn how to use Windows PowerShell for administrative tasks.


You can find the Windows PowerShell for Sharepoint Command Builder here:
http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html

or can download its guide from the following link:
http://www.microsoft.com/en-us/download/details.aspx?id=27588



Choose the product that you want to create PowerShell commands for - in this example SharePoint Online.
You have option to choose one of the following products:

  • SharePoint Online
  • SharePoint Foundation 2013
  • SharePoint Server 2013
  • SharePoint Foundation 2010
  • SharePoint Server 2010
  • Office 365

Once you have selected a product from the product list, you can drag and drop 1 verb and 1 noun from available lists on the left, to the designated area on the right.

In this example I choose "Get" as my verb and "Site" as noun:


Based on Verb and Noun that you choose, tool will present the additional parameters that you can configure for the command which will appear in "Required" and "Optional" panes.

At the end you can grab the final command from the information box on the bottom left of the page. in this example the generated command is as follows:
Get-SPOSite -Identity "https://adoptcloud.sharepoint.com " -Limit "1"