Office as a Platform, Issue 7 - Manage Office 365 and SharePoint Online through PowerShell

    Here is a continuation of the series of articles on developing 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. You can always find all the articles in the Office as Platform column under 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 only with SPO.

    Connect to an Office 365 instance


    For further work, make sure that you are a subscription administrator. Otherwise, you will not get access.

    Before you begin, install the following required modules


    Use the following lines to connect to SharePoint Online Administration
    Import-Module Microsoft.Online.Sharepoint.PowerShell
    $ credential = Get-credential
    Connect-SPOService -url contoso-admin.sharepoint.com -Credential $ credential

    Check out the full list of available cmdlets for SharePoint Online here .

    Two examples of use


    Let's look at two simple scenarios for using PowerShell cmdlets to manage SharePoint Online.

    Removing a site collection
    Import-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 file

    For 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

    Script listing
    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}

    Limitations


    As you noticed, the set of PowerShell cmdlets for SharePoint Online is an order of magnitude smaller than the on-premises version of SharePoint. If you're curious about how to get around this limitation, check out Chris O'Brien Using CSOM in PowerShell scripts with Office 365 .

    useful links



    What's next?


    In the following articles of the series, we’ll talk about publishing applications in the Office Store, connecting to Office 365 from various applications, working with the Office Graph API, issues of code migration and transfer, and organizing continuous development. Stay tuned!

    For authors


    Friends, if you are interested in supporting the column with your own material, please write to me at vyunev@microsoft.com in order to discuss all the details. We are looking for authors who can interestingly talk about development for Office and other topics.

    about the author


    Plotnikov Dmitry Alexandrovich
    Founder and SharePoint Consultant @ PlotnikovSoft

    Microsoft MVP since 2011, I have a personal blog about SharePoint and Office 365. I lead a small company for the implementation and maintenance of enterprise systems based on SharePoint / Office365.

    Only registered users can participate in the survey. Please come in.

    As a SharePoint developer, are you interested in SharePoint Online?

    • 72.7% Yes, more material and articles needed 8
    • 18.1% Not sure, need more information 2
    • 9% So far, developing only for regular SharePoint 1

    Also popular now: