Sunday, 19 March 2017

Export SharePoint online site collection lists to file using PowerShell

Sometimes we come across this requirement to provide a list with all SharePoint online site collection details with name and url. This is basically used for report or information purpose.

So we need to extract this information to a file so that can be sent through an email or uploaded to a SharePoint library and shared easily with someone.

To do this we will use SharePoint Online Management Shell. I have mentioned how you can open SharePoint Online Management Shell in this post.

Now open SharePoint Online Management Shell and do the following:
  • Type below command replacing the url with your SharePoint admin center url. Please note word -admin in the url, you can place it by typing or copy the url directly from browser by navigating to SharePoint admin center. To know how to navigate to SharePoint admin center you can check here.
          Connect-SPOService -Url https://companyname-admin.sharepoint.com
          
         After hitting enter it will ask for credentials. Provide the credentials and click OK. This user
        must be a member of the tenant’s Global Admin or SharePoint Administrator role.
  • Then type below 2 lines of script by replacing the folder path with the one where you want to generate the file "SPOSiteCollDetails.txt"
        $siteCollList = Get-SPOSite | select Title,Url 
        $siteCollList > D:\SPOSiteCollExport\SPOSiteCollDetails.txt

After successful execution it would generate the file with Title and Url that looks like:












In my next post we will see how to generate a report based on allocated storage and current usage of SharePoint online site collection.

No comments:

Post a Comment