I'm implementing some PowerShell scripts for helping my team create new SharePoint Online sites. One of these scripts follows these requirements:

  • be able to create a site,
  • be able to remove the site if previously exists,
  • be able to return the site created

Seems to be easy using the SharePoint Online Management Shell and that's it but I'm facing an issue that throws the following error:

Get-SPOSite : Error in proc_GetSitesAllowDenyList, no rowset returned.

I get it sometimes, not always, but don't know why and don't find any explanation about it googling. Let me share my code and try to explain it:

    # Obtains the site if exists
    $Instance = Get-SPOSite $Url

    # Removes the site in case that exists and user requires
    If($null -ne $Instance -and $true -eq $RemoveIfExists) {
        Write-Host "Removing site "$Url"..."

        Remove-SPOSite $Url -Confirm:$false
        Remove-SPODeletedSite $Url -Confirm:$false

        $Instance = $null

    # Creates the site if not exists
    If($null -eq $Instance) {
        Write-Host "Creating site "$Url"..."
        $Instance = New-SPOSite -Owner $Owner -Url $Url -Title $Title -StorageQuota $Quota -Template $Template

    # Returns the site
    Get-SPOSite $Url

As I said, seems that everything runs perfectly fine but when reaching the last line throws the error. Do you think that I need to add some delay to let SharePoint/Office 365 completely do all the stuff need before retrieving the site?

  • 1
    yep, would suggest adding some delay. It looks like it is taking some time to clear the site collections. – Gautam Sheth Feb 26 '19 at 18:32
  • 1
    yes, creating SC on SPO can takes from 1-60 minutes :) so you need to create delay – Zdeněk Vinduška Feb 27 '19 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.