powershellsharepointsitecollection

Is there a way to tell when a site is created and ready to use when creating it using powershell?


I'm creating a number of sites using a powershell script. Now, when each of the sites is finished, I want to activate features on it.

My problem is that when I do this, it takes some time before the site is ready. Especially in SharePoint Online it is hard to predict when the site is ready. I've tried using time-loops, but I was wondering if there is a status setting somewhere that I can query instead.

Any thoughts?


Solution

  • Actually we solved the problem. The siteCreationOperation has a property named isComplete. Iterate over this and pick up the boolean for further processing :)

    https://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantadministration.tenant.createsite(v=office.15).aspx

        #Create the site using the properties
        $tenant.CreateSite($properties) | Out-Null
        ...
        ...
        $siteCreationOperation = $tenant.CreateSite($properties)
        $ctx.Load($siteCreationOperation)
        ...
        ...
        #Create the site in the tennancy
        ...
        ...
        do
        {
            ...
            ...
            $ctx.Load($siteCreationOperation)
            $ctx.ExecuteQuery()
            Write-Host $siteCreationOperation.IsComplete
            ...
            ...
        }
        ...
        while (!$siteCreationOperation.IsComplete)
        ...