Wednesday, July 24, 2013

How to delete an orphaned Project Server Site

Let's say you go to provision a Project Web App via managed service applications, project server server application, and it fails.  There is a chance that the particular site you are trying to provision is orphaned within the Project Server Service Application.

this occurs after the Site collection that held the PWA site is deleted before it is unprovisioned.  And sometimes it occurs even if the PWA site is unprovisioned and then deleted.

The advice listed by Alexander on this technet forum, works

PS C:\Users\sp_farm>Get-SPServiceApplication
mark out the GUID for the project service application

PS C:\Users\sp_farm>$psi = get-spserviceapplication | ? {$_.Id -eq "GUID of the Project Service App from above"}
PS C:\Users\sp_farm> $a = $psi.Sitecollection | where {$_.SiteID -eq "< Guid of the orphaned site, see text below on how to find this>"}
PS C:\Users\sp_farm>
PS C:\Users\sp_farm> $a
PS C:\Users\sp_farm>
PS C:\Users\sp_farm> $a.Delete()

to test this series of commands, after you've ran the above you can perform the following steps, and actually you can perform these steps to get the guid that you need in the above "<Guid>"

From an administrative management console, type


then Mark the GUID for the Project Service App and run

$sa = get-spserviceapplication | ? {$_.Id -eq "GUID of the Service App from above"}

followed by

 $sc = $sa.SiteCollection

The guid associated with the SiteID is guid that you're after, you can find this a few rows above the name field.

"Details of what each section of the above powershell commands are returning are neatly documented in this technet post by Alex Burton -"

Notice how, if you run $sc by itself, it will show you all the site collections that the project service application thinks are in place.  After you run

$a = $psi.Sitecollection | where {$_.SiteID -eq "< Guid>"}



when you run $sc, it will contain one less, based on the siteID used in the <Guid> of 

$a = $psi.Sitecollection | where {$_.SiteID -eq "< Guid>"}


  1. Hey, Just wanted to thank you.
    I've tried everything (scripts) and yours was the one that worked.
    I've adjusted it to my environement this was what I did:

    # Get-SPServiceApplication
    # $psi = Get-SPServiceApplication | ? {$_.Id -eq "d8abe800-8b52-424b-b1a4-0b640055630f"}
    # $psi
    # $sc = $psi.SiteCollection
    # $sc
    # really bogus SiteID 0000000-...
    # $a = $psi.SiteCollection | where {$_.SiteId -eq "00000000-0000-0000-0000-000000000000"}
    # $a.Delete()
    # huge difference between Remove and Delete ;) thanks!!!!
    # $sc
    # This last command returned empty. after this I went in to the Central Admin -> Manage Service Applications,
    # Selected the Project Server 2013 Service Application and just deleted it with associated content database



Thanks for commenting, if you have a question and want a reply, please post it on TechNet forums and reference this blog, or navigate to and post it there, all of these blog posts and more are on my SharePoint Papa site.

Popular Posts