First, make sure you installed SharePoint Online Management Shell on your PC and install the SPO modules using below commands. (use -Force parameter to install new version if old version already exists).
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force
Install-Module SharePointPnPPowerShellOnline
Go thru the blog to >> Connect-SPOService
Create new site/site collection
Below is the default syntax. We can pick required parameters.
(Note: You must be a SharePoint Online global administrator to run the cmdlet).
New-SPOSite
[-CompatibilityLevel <Int32>]
[-LocaleId <UInt32>]
[-NoWait]
-Owner <String>
[-ResourceQuota <Double>]
-StorageQuota <Int64>
[-Template <String>]
[-TimeZoneId <Int32>]
[-Title <String>]
-Url <UrlCmdletPipeBind>
[<CommonParameters>]
Use the Get-SPOWebTemplate cmdlet to get the list of valid templates. If no template is specified, one can be added later.
The below customized Powershell cmdlet as per our requirement.
New-SPOSite -Url https://gurram.sharepoint.com/sites/hr -Owner gvr@gurram.onmicrosoft.com -NoWait -Template STS#0 -Title "HR"
New site collection was created.
Delete site/site Collection
The Remove-SPOSite cmdlet does not delete a site collection from the site collections list permanently. Instead, the removed site collection is moved to the Recycle Bin. Below is the default syntax. We can pick required parameters.
(Note: You must be a SharePoint Online global administrator and a site collection administrator to run the cmdlet).
Remove-SPOSite
[-Confirm]
-Identity <SpoSitePipeBind>
[-NoWait]
[-WhatIf]
[<CommonParameters>]
The below customized Powershell cmdlet as per our requirement.
Remove-SPOSite -Identity https://gurram.sharepoint.com/sites/hr -NoWait
Click on Yes or Yes to All.
The removed site collection was moved to the Recycle Bin.
_______________________________________________________________
Restore site/site Collection.
Use the Restore-SPODeletedSite cmdlet to restore a site collection from the Recycle Bin.
Below is the default syntax. We can pick required parameters.
(Note: You must be a SharePoint Online global administrator and a site collection administrator to run the cmdlet).
Restore-SPODeletedSite
-Identity <SpoSitePipeBind>
[-NoWait]
[<CommonParameters>]
The below customized Powershell cmdlet as per our requirement.
Restore-SPODeletedSite -Identity https://gurram.sharepoint.com/sites/hr -NoWait
The site collection was restored.
_______________________________________________________________
Delete site/site Collection permanently.
The Remove-SPODeletedSite cmdlet permanently removes a SharePoint Online deleted site collection from the Recycle Bin. Below is the default syntax. We can pick required parameters.
(Note: You must be a SharePoint Online global administrator and a site collection administrator to run the cmdlet).
Remove-SPODeletedSite
[-Confirm]
-Identity <SpoSitePipeBind>
[-NoWait]
[-WhatIf]
[<CommonParameters>]
The below customized Powershell cmdlet as per our requirement.
Remove-SPODeletedSite -Identity https://gurram.sharepoint.com/sites/hr -NoWait
Removed the SharePoint Online deleted site collection from the Recycle Bin and deleted it permanently.
No comments:
Post a Comment