POWERSHELL COMMANDS ON SHAREPOINT ONLINE SITES
PowerShell commands for SharePoint Online (SPO) greatly simplify administration tasks such as site management, permissions handling, and reporting. The SharePoint Online Management Shell provides a collection of cmdlets (commands) starting with "SPO" or "PnP" (for PnP PowerShell) that administrators use to automate and streamline management.
Commonly Used PowerShell Commands on SharePoint Online Sites
Connect to SharePoint Online Admin Center
powershellConnect-SPOService -Url https://<tenant>-admin.sharepoint.comEstablishes a session with the SharePoint Online admin center.
Get List of Site Collections
powershellGet-SPOSiteRetrieves all SharePoint Online site collections in your tenant.
Get Detailed Site Information
powershellGet-SPOSite -Identity https://contoso.sharepoint.com/sites/siteName -DetailedProvides detailed properties of a specific site.
Create a New Site Collection
powershellNew-SPOSite -Url https://contoso.sharepoint.com/sites/newsite -Owner user@contoso.com -StorageQuota 1024 -Template STS#0 -Title "New Site"Creates a new site with specified owner, storage quota, template, and title.
Update Site Collection Properties
powershellSet-SPOSite -Identity https://contoso.sharepoint.com/sites/siteName -StorageQuota 2048 -Title "Updated Title"Modifies settings like storage quota and title for an existing site.
Remove a Site Collection
powershellRemove-SPOSite -Identity https://contoso.sharepoint.com/sites/oldsiteDeletes a specified site collection.
Manage Site Collection User Permissions
Add user to site owners group:
powershellAdd-SPOUser -Site https://contoso.sharepoint.com/sites/siteName -LoginName user@contoso.com -Group "Site Owners"Remove user from a group:
powershellRemove-SPOUser -Site https://contoso.sharepoint.com/sites/siteName -LoginName user@contoso.com -Group "Site Members"
Get Site Collection Storage Usage
powershellGet-SPOSite | Select URL, StorageUsageCurrent | Format-TableLists site URLs and their current storage usage.
Restore a Deleted Site
powershellRestore-SPODeletedSite -Identity https://contoso.sharepoint.com/sites/deletedsiteUsing PnP PowerShell for More Granular Tasks
Connect to site:
powershellConnect-PnPOnline -Url https://contoso.sharepoint.com/sites/siteName -InteractiveGet all lists:
powershellGet-PnPListAdd user to SharePoint group:
powershellAdd-PnPGroupMember -Identity "Site Members" -LoginName user@contoso.com
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.