SharePoint Online PowerShell
The SharePoint Online Management Shell: sites, sharing and tenant settings.
Official documentation- Get-SPOSite: Cannot bind parameter 'Identity'. Cannot convert value to type "SpoSitePipeBind"SPO cmdlets such as Get-SPOSite and Set-SPOSite take only the full site URL in -Identity. A title, a /sites/ path, a URL without https or an object fails.
- Connect-SPOService : Current site is not a tenant administration site.Connect-SPOService needs the admin center URL, https://TENANT-admin.sharepoint.com, not a site or the root URL. Use the -admin host and a SharePoint admin.
- No connection available. Use Connect-SPOService before running this CmdLet.SharePoint Online Management Shell cmdlets like Get-SPOSite and Set-SPOTenant need a session. Run Connect-SPOService with your tenant's -admin URL first.
- Set-SPOTenant: Cannot bind parameter 'SharingCapability'. Cannot convert value "Anyone"-SharingCapability takes enum names, not admin center labels: Anyone is ExternalUserAndGuestSharing, New and existing guests is ExternalUserSharingOnly.
- Get-SPOSite storage usage: StorageUsageCurrent and StorageQuota for every siteGet-SPOSite -Limit All lists each site's StorageUsageCurrent and StorageQuota in MB. Add -IncludePersonalSite for OneDrive; set quotas with Set-SPOSite.
- Restore-SPODeletedSite: restore a deleted SharePoint Online site with PowerShellDeleted SharePoint Online sites stay 93 days in the recycle bin. Find them with Get-SPODeletedSite and bring one back with Restore-SPODeletedSite -Identity URL.
- Set-SPOSite -LockState: make a SharePoint Online site read-only or block accessSet-SPOSite -Identity URL -LockState ReadOnly makes a SharePoint site read-only, NoAccess blocks it with a 403 or redirect, and Unlock restores normal access.
- Set-SPOUser -IsSiteCollectionAdmin: add a site collection admin in SharePoint Online or OneDriveSet-SPOUser -Site URL -LoginName UPN -IsSiteCollectionAdmin $true makes a user site collection admin of a SharePoint site or OneDrive. It takes a Boolean.
- Get-SPOSite -IncludePersonalSite $true: include OneDrive sites in the listGet-SPOSite -IncludePersonalSite $true adds OneDrive sites, which are excluded by default. It is a Boolean, not a switch; how to list only OneDrive URLs.
- Get-SPOSite -Limit All: list every site, not just the first 200Get-SPOSite returns 200 site collections by default; -Limit All returns every site. The parameter is a string; filters, templates and missing properties.
- Set-SPOSite -DenyAddAndCustomizePages 0: allow custom scripts on a SharePoint siteSet-SPOSite -DenyAddAndCustomizePages 0 allows custom script on a SharePoint site for at most 24 hours; 1 blocks it again. Accepted values tested offline.
- Set-SPOSite -StorageQuota: set a site storage limit in MB (with a warning level)Set-SPOSite -StorageQuota and -StorageQuotaWarningLevel take megabytes, not GB. Convert with 50GB/1MB; manual vs pooled storage and -StorageQuotaReset.
- OneDrive retention for deleted users: Set-SPOTenant -OrphanedPersonalSitesRetentionPeriodOrphanedPersonalSitesRetentionPeriod is how many days a deleted user's OneDrive is kept, 30 to 3650 (default 30). Set it with Set-SPOTenant; policies win.
- SharePoint Online SharingCapability: Set-SPOTenant and Set-SPOSite external sharing valuesSharingCapability sets external sharing for the tenant (Set-SPOTenant) or one site (Set-SPOSite). Values, admin center labels and how site and tenant combine.