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

Get-SPServiceApplication

 
mark out the GUID for the project service application

$psi = get-spserviceapplication | ? {$_.Id -eq "GUID of the Project Service App from above"}
$a = $psi.Sitecollection | where {$_.SiteID -eq "< Guid of the orphaned site, see text below on how to find this>"}
$a
$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

Get-SpServiceApplication

 

then Mark the GUID for the Project Service App and run

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

 

followed by

$sc = $sa.SiteCollection
$sc

 

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 – http://social.technet.microsoft.com/Forums/projectserver/en-US/3c39d249-63a1-41fa-9440-3611e3f3d65c/event-id-7626-cannot-start-queue-url-queue-timesheetq?prof=required”

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>"}

 

then

$a.Delete()

 

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>"}