Thursday, August 4, 2011

ProjectServer 2010: PSI from PowerShell

Great news for ProjectServer 2010 developers and administrators!

We've just released a FluentPS PowerShell snap-in, which brings a full power of FluentPS library to PowerShell.

Features list:
- Create/update/delete Custom Fields and Lookup Tables
- Read/Check In/Check Out/Publish projects
- Manage security groups and categories
- Add/remove event handlers
- Manage EPTs and PDPs
- Read users and resources

Quick Start

First of all download FluentPS.PowerShell.dll and install a FluentPS snapin (run as Administrator):

set-alias installutil $env:windir\Microsoft.NET\Framework64\v2.0.50727\installutil
installutil FluentPS.PowerShell.dll

Add spnapin to the session:

Add-PSSnapIn FluentPSSnapIn

And here we go!
See usage example:

$fluentps = Get-FluentPS -PWAUrl http://SERVER/PWA

# Read projects list

#Check in project
$ProjectName = "Test2"
$sessionUid = [System.Guid]::NewGuid()
$ProjectUid = ($fluentps.ProjectService.GetAll() | where {$_.Name -eq $ProjectName}).Uid

$CheckInJobUid = $fluentps.ProjectService.CheckIn($Projectuid, $sessionUid)
$IsCheckInJobComplete = $fluentps.QueueSystemService.WaitForQueue($CheckInJobUid)

If ($IsCheckInJobComplete )
 Write-Host "Project $ProjectName has been checked-in"
 $PublishJobUid = $fluentps.ProjectService.Publish($ProjectGuid, $false)
 $IsPublishJobComplete = $fluentps.QueueSystemService.WaitForQueue($PublishJobUid)
if ($IsPublishJobComplete)
  Write-Host "Project has been published successfully"
  Write-Error "Project has NOT been published successfully"
 Write-Error "Project $ProjectName has NOT been checked-in"

Have fun!