Creating SPO Site Using Powershell

Introduction

PNP Power shell provides robust and yet powerful features to create sites. When using the SPO module it is required to have a checkpoint to check if any of the sites exist in deleted sites, that means whenever a site collection is deleted, the site will be moved to the recycle bin for 90 days, and after that the site will be cleaned up. During this time, if you want to create a site collection with the same site name, it is not possible unless you delete the deleted site collection from the admin recycle bin. 

In PnP Powershell, you can take advantage of the parameter 'RemoveDeletedSite'. This means it checks for the deleted object in the recycle bin, if it finds it silently cleans up and then provisions the required site collection.

Below is the error you would be getting if you have the same URL existing in the SharePoint admin recycle bin.

Creating SPO Site Using Powershell

It basically says 'Creation request for a Site Collection with URL while another site collection with the same Url exists in Recycle Bin is not allowed!'

PowerShell Command

Please note that Title, URL, Owner names are mandatory. 

New-PnPTenantSite -Title "MyTestsite1" -Url "https://contoso.sharepoint.com/sites/mytestsite1" -Owner "vinay@contoso.com" -TimeZone 11 -RemoveDeletedSite

Substitute Title, URL, owner, and Timezone to your required values. 

Hope you find this helpful.