Powershell: Project Server Set-SPProjectWebInstance & SQL Mirror

If you have to mirror SQL Project Server database, You will find 2 things among a lot:

  • Set-SPProjectWebInstance providing PrimaryDBMirrorServer and ReportingDBMirrorServer
  • AddFailoverServiceInstance
From my tests, the last one is not enough. Here start the pleasure of non ended cmdlet..Still works about them. The Get- can’t show properties add with the Set-…

So no way to find if it’s already done or good..Here is a script that
:

  • get all PWA URLthrough service application 
  • Remove the “/” on ending url (else the cmdlet Set- throw an error !)
  • Put back all existing settings and add the mirror server

 

$work=Get-SPServiceApplication | ?{$_.DisplayName -match"Project"} | Get-SPProjectWebInstance 
foreach ($item in $work) 
{ 
Write-Output"doing $($item.url)" 
$mirror=$item.PrimaryServer -replace ("sqlone","sqltwo") 
Set-SPProjectWebInstance -Url ($item.Url).ToString().TrimEnd('/') ` 
-AdminAccount $item.AdminAccount ` 
-PrimaryDbserver $item.PrimaryServer ` 
-ArchiveDbname $item.ArchiveDatabase ` 
-DraftDbname $item.DraftDatabase ` 
-PublishedDbname $item.PublishedDatabase ` 
-ReportingDbServer $item.ReportingServer ` 
-ReportingDbname $item.ReportingDatabase ` 
-PrimaryDBMirrorServer $mirror` 
-ReportingDBMirrorServer $mirror } 

Leave a Comment