In SharePoint Online, a Site Collection is the top-level site that contains subsites, libraries, and lists. Using PnP PowerShell, administrators can efficiently create Modern Team Sites, Communication Sites, and Classic Team Sites without using the SharePoint Admin Center.
This guide covers:
Installing & Connecting to SharePoint Online
Creating Different Types of SharePoint Sites
Configuring Site Collection Settings
Step 1: Install & Connect to SharePoint Online
Install PnP PowerShell (If Not Installed)
Install-Module PnP.PowerShell -Scope CurrentUser -Force
Connect to SharePoint Online
For MFA-enabled accounts:
Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -Interactive
For App-Only authentication (used for automation):
Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -ClientId "<App_ID>" -Tenant "<Tenant_ID>" -CertificatePath "C:\PnPCert.pfx"
Step 2: Create a New SharePoint Site Collection
PnP PowerShell allows you to create Modern and Classic SharePoint sites.
Create a Modern Team Site (Without Microsoft 365 Group)
New-PnPSite -Type TeamSiteWithoutGroup -Title "Project Alpha" -Url "https://yourtenant.sharepoint.com/sites/ProjectAlpha" -Owner "admin@yourtenant.com"
✔ Ideal for departmental collaboration
✔ No Microsoft 365 group linked
Create a Communication Site
New-PnPSite -Type CommunicationSite -Title "Company News" -Url "https://yourtenant.sharepoint.com/sites/CompanyNews"
✔ Used for broadcasting information
✔ No Microsoft 365 Group integration
Create a Classic Team Site
New-PnPSite -Type TeamSite -Title "Classic Team" -Url "https://yourtenant.sharepoint.com/sites/ClassicTeam"
✔ Supports custom web templates & features
✔ Used in legacy SharePoint environments
Step 3: Configure Site Collection Settings
Set Site Quota (Storage Limit)
Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/ProjectAlpha" -StorageQuota 10240
Storage quota is in MB (10 GB in this case).
Enable or Disable External Sharing
Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/ProjectAlpha" -SharingCapability ExternalUserSharingOnly
Options:
Disabled
(No external sharing)ExternalUserSharingOnly
(Share with external users with sign-in)ExternalUserAndGuestSharing
(Anonymous links allowed)ExistingExternalUserSharingOnly
(Only pre-approved external users)
Set a Site Collection Administrator
Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/ProjectAlpha" -Owners "admin@yourtenant.com"
Admins have full control over the site.
Step 4: Retrieve and Verify Site Collections
List All Site Collections in the Tenant
Get-PnPTenantSite
Get Details of a Specific Site
Get-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/ProjectAlpha"
Step 5: Delete and Restore a SharePoint Site Collection
Move Site to Recycle Bin
Remove-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/OldSite"
The site moves to Deleted Sites and can be restored.
Restore a Deleted Site
Restore-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/OldSite"
Only possible within 93 days of deletion.
Permanently Delete a Site
Remove-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/OldSite" -Force
Warning: This cannot be undone.
Step 6: Disconnect from SharePoint Online
Once done, disconnect the session:
Disconnect-PnPOnline
Common Issues & Troubleshooting
Issue: “Access Denied”
✔ Solution: Ensure your account has SharePoint Admin or Global Admin privileges.
Issue: “Site already exists”
✔ Solution: Run Get-PnPTenantSite
to check if the site URL is in use.
Issue: “The requested operation is blocked by policy”
✔ Solution: Your tenant might have restrictions on site creation. Check with your administrator.