Before proceed Install the SharePoint Online Management Shell:
a. Download SharePoint Online Management Shell
b. Run the installer
c. Once you have installed the downloaded setup, run the below command to load this module
Note: If powershell console already opened, close and open the powershell again after installing the above setup.
We need admin site url to connect SharePoint Online service, you can refer this post to Get SharePoint Online Admin Site Url. Once you got the admin site url run the below script after replacing your AdminUrl to list all sites.
#Replace your admin site url
$AdminUrl = "https://contoso-admin.sharepoint.com/"
#Retrieve all site collections
Connect-SPOService -Url $AdminUrl
Get-SPOSite | Select Title, Url, Owner
If you want to retrieve all the available properties, run the below command, it will list all the attributes of first site.
You can also filter the sites based on any available property, the below command lists only sites with sharing capability enabled as ExternalUserSharingOnly.
Run the below command to list sites with share capability disabled.
Export all SharePoint Online Sites to CSV
Run the below command to export all the required details of spo sites to csv file.
Get-SPOSite | Select Title, Url, Owner, SharingCapability, LastContentModifiedDate |
Export-CSV "C:\SharePoint-Online-Sites.csv" -NoTypeInformation -Encoding UTF8