This is a continuation of a series of articles on the development of cloud applications for Office 365 SharePoint Online. In this article in the series, Dmitry Plotnikov, a SharePoint consultant, talks about managing Office 365 and SharePoint Online using PowerShell. All articles in the column “Office as Platform” you can always find at the link #officeplatform - Vladimir Yunev.
In Office 365, PowerShell is used to work with the products included in the package — SharePoint Online, Exchange, and Skype For Business. This article discusses the scenario of working with SPO only.
Connect to an Office 365 instance
For further work, make sure you are a subscription administrator. Otherwise, you will not get access.
Before you start, install the following required modules.
Use the following lines to connect to the administration of SharePoint Online
Import-Module Microsoft.Online.Sharepoint.PowerShell
$ credential = get-credential
Connect-SPOService -url contoso-admin.sharepoint.com -Credential $ credential
View the full list of available cmdlets for SharePoint Online
here .
')
Two examples of use
Consider the two simplest scenarios for using PowerShell cmdlets to manage SharePoint Online
Deleting a site collectionImport-Module Microsoft.Online.Sharepoint.PowerShell
$ credential = get-credential
Connect-SPOService -url contoso-admin.sharepoint.com -Credential $ credential
Remove-SPOSite -Identity contoso.sharepoint.com/sites/SiteCollectionName -NoWait
Creating multiple sites from a CSV fileFor example, use a CSV file with the following contents.
Name, URL, Owner, StorageQuota, ResourceQuota, Template
Contoso Team Site, https: //contoso.sharepoint.com/sites/TeamSite,user1@contoso.com,1024,300,STS#0
Contoso Blog, https: //contoso.sharepoint.com/sites/Blog,user2@contoso.com,512,100,BLOG#0
Listing script
Import-Module Microsoft.Online.Sharepoint.PowerShell
$ credential = get-credential
Connect-SPOService -url contoso-admin.sharepoint.com -Credential $ credential
Import-Csv. \ NewSPOSites.csv | % {New-SPOSite -Owner $ _. Owner -StorageQuota $ _. StorageQuota -Url $ _. Url -NoWait -ResourceQuota $ _. ResourceQuota -Template $ _. Template -Title $ _. Name}
Restrictions
As you noticed, the set of PowerShell cmdlets for SharePoint Online is an order of magnitude smaller compared to the local version of SharePoint. If you're wondering how to get around this limitation, read the Chris O'Brien
Using CSOM in PowerShell scripts with Office 365 article.
useful links
What's next?
The following articles of the cycle will cover the publishing of applications in the Office Store, connecting to Office 365 from various applications, working with the Office Graph API, issues of migration and code migration, organization of continuous development. Stay tuned!
To authors
Friends, if you are interested in supporting the column with your own material, please write to me at
vyunev@microsoft.com to discuss all the details. We are looking for authors who can be interesting to tell about the development under Office and other topics.

about the author
Plotnikov Dmitry Alexandrovich
Founder and SharePoint Consultant @ PlotnikovSoft
Microsoft MVP since 2011, I keep a
personal blog about SharePoint and Office 365. I am a small company in the implementation and maintenance of corporate systems based on SharePoint / Office365.