A few people have written about PowerShell provisioning of PWA in 2013, see here and here, both reference this TechNet source. However if you’re anything like me you might find these confusing! Coming from 2010 it seems that everything has changed, so after struggling a bit using the above three references trying to update my old automated PWA deployment scripts I figured that it can’t hurt to have one more guide online covering the process.
Look No Site Collection
Firstly though, one of the great things about 2013 is that PWA is now uncoupled from its Site Collection, basically /PWA no longer needs to be a Site Collection but can be any regular site.
Esoteric as that may sound it means that we no longer have this odd divide where Project data such as Project Sites live in various “SharePoint Intranet” site collections and PWA has to be in it’s own isolated space with different users, permissions, features, etc. Clearly this is geared towards supporting SharePoint permissions mode and generally making Project more SharePoint friendly, but combined with those nifty new license management features things become very much easier for many of us dealing with real world deployment scenarios.
This also has the added bonus of making it easier to provision PWA at the root site collection (in a more standard way – ick Site Collection host headers!).
Get to the setup
The challenge I had with the scripted setup links above was that they seemed to be missing something, for instance the TechNet article misses the whole site collection creation part and so then confuses things by splitting off into a separate article on creating PWA in an existing site collection? Is it just me or was that really confusing?
Anyway here’s my PowerShell script for provisioning a new PWA instance in a new Site Collection where the root site collection contains a Team Site and PWA is in the familiar location /PWA.
$SiteUrl = "https://"+$HostHeader $PWASiteUrl = "https://"+$HostHeader+$PWAPath $SiteCollectionOwner="i:0#.w|domain$($AdminUser)" $SecondaryOwnerAlias="" $PWADatabase="ProjectWebAppDB" $DatabaseServer = "sqlservername" $PWAAbbreviation = "PWAInstance1" $svcApp = Get-SPServiceApplication | ? {$_.TypeName -eq 'Project Application Services'} $webapp = Get-SPWebApplication -Identity $SiteUrl Write-Host "Creating Project Server database:" $PWADatabase New-SPProjectDatabase -Name $PWADatabase -ServiceApplication $svcApp ` -DatabaseServer $DatabaseServer -Tag $PWAAbbreviation ` -ErrorVariable err if ( $err ) { write-host "An Error Occured: " $err -ForegroundColor Red break } Write-Host "Creating Team Site root for PWA" $SiteUrl " Owner:" $SiteCollectionOwner $site = New-SpSite -url $SiteUrl ` -owneralias $SiteCollectionOwner ` -SecondaryOwnerAlias $SecondaryOwnerAlias ` -ErrorVariable err if ( $err ) { write-host "An Error Occured: " $err -ForegroundColor Red break } Write-Host "Creating PWA Web: " $PWASiteUrl " Owner:" $SiteCollectionOwner $web = New-SPweb -URL $PWASiteUrl -Template pwa#0 $web=Get-SPWeb $SiteUrl $web.Properties["PWA_TAG"] = $PWAAbbreviation $web.Properties.Update() Write-host "Enabling PWASite features..." Enable-SPFeature pwasite -URL $SiteUrl
I lifted that from my mass deployment script (woo 2,600 lines and counting) so after my little rant above please excuse me if I forgot to declare one of the variables or something.
Hope this helps someone!
This article is republished with permission here: EPMonDemand Blog
I needed to thank you for this excellent read!! I definitely loved every bit
of it. I have you bookmarked to look at new stuff
you post…
Great job!
I Wonder if in that case saving the 2013 PWA site collection is effective now ? in version 2010 it was forbiden.
This could be great to restore a Project instance, without restoring the whole SP farm. What do you think ?
Yes you can, I have restored individual site collections which contain PWA sites underneath them without having to restore anything other than the specific content DB and single Project DB.
Martin,
Great article, can I use the same script for HNSC, I already have a existing host named site collection.
Here is my scenario:
webapp – http://Projapps
Host named site coll inside above webapp – http://project.contoso.com
I want to create PWA on the HNSC – http://project.contoso.com/PWA
Can you please help me out, I am redoing my proj server
Thank you
Neal
Hi Neal,
Yes you can, I recently did just that actually and provisioned (actually migrated) a PWA site to ‘https://projects.customer.com/’ on the root site, so it definitely works!
The change in the script above is simple, on line 24 the “New-SPSite” command add the following extra parameter:
-HostHeaderWebApplication “http://Projapps”
With the url being the existing Web application, then simply the full host name as the $SiteURL and $PWAUrl’s.
Martin