Saturday, November 15, 2025

SharePoint Online sites and using PowerShell

1.  To retrieve all SharePoint Online sites and export the data using PowerShell

# Connect to SPO admin center

Connect-SPOService -Url "https://<yourtenant>-admin.sharepoint.com"


# Retrieve all site collections and export to CSV

Get-SPOSite -Limit All | Select Title,Url,Template,StorageQuota,LastContentModifiedTime,Owner | Export-Csv -Path "C:\Temp\AllSharePointSites.csv" -NoTypeInformation


2. PowerShell script to get all licensed Microsoft 365 users:

# Install the MSOnline module if not already installed

Install-Module -Name MSOnline -Force


# Import the module

Import-Module MSOnline


# Connect to Microsoft 365

Connect-MsolService


# Get all users with any assigned license and export to CSV

$LicensedUsers = Get-MsolUser -All | Where-Object { $_.IsLicensed -eq $true }

$LicensedUsers | Select DisplayName, UserPrincipalName, Licenses | Export-Csv -Path "C:\Temp\LicensedUsers.csv" -NoTypeInformation




No comments:

Post a Comment

Note: Only a member of this blog may post a comment.