Quantcast
Viewing latest article 4
Browse Latest Browse All 10

“Object already exists” when using ProvisionGlobally

In two earlier posts I have written about how to create and extend a web application using PowerShell. Today I ran in to a problem when I extended a Web Application twice directly after each other.

The error message I got was:

Exception calling “ProvisionGlobally” with “0″ argument(s): “An object of the type Microsoft.SharePoint.Administration. SPWebApplicationProvisioningJobDefinition named “Provisioning 0615878b-f543-43ab-aeb8-c59080cd52a8″ already exists under the parent Microsoft.SharePoint.Administration.SPWebService named “”. Rename your object or delete the existing object.”

This is because SharePoint creates a  timer job that runs once to provision the Web Application out to all WFE’s. So in this case when we extend the same Web Application, the job will have the same name and sometimes (almost all the time if you have more then one WFE) the timer job doesn’t get finished and there is your conflict. You can follow this process in Central Administration under Operations and Timer Job Status while you run your script.

The easiest way to solve this is to insert a sleep in to your script looking something  like this:

Start-Sleep -s 30

-s indicates how many seconds to wait so in this case 30 seconds.

But I wanted to make it a bit more sophisticated so I made a for each loop where I check if there is any provisioning job running, and if it is, wait another 30 sec.

To be able to do this we first need a reference to the farm and then to the Service running the Provisioning jobs. The Service is called “Windows SharePoint Services Web Application” so by looping through the JobDefinitions of that service, and look for a one named “Provisioning Web Application” we know if we need to wait some more or we can continue extending the Web Application.

This is how the script looks like:

$farm=[Microsoft.SharePoint.Administration.SPFarm]::Local

$Service = $farm.Services | Where { $_.TypeName -eq “Windows SharePoint Services Web Application”}

 while ($Service.jobdefinitions | where { $_.Title -like “*Provisioning Web Application*” } ){

 Write-Host “The ‘” $Service.jobdefinitions.Title “‘ job are still running. Waiting 30 sec to provision ” $_.WebAppDisplayName

  Start-Sleep -s 30

  }


Viewing latest article 4
Browse Latest Browse All 10

Trending Articles