The following script is a sample of what an administrator may want
to publish a specific project using PowerShell. The script reads the
list of existing projects in Project Server and publishes project based
on the project name. Set the $url variable to point to the desired
instance of Project Server, and then run the script.
$path = "c:\program files (x86)\Microsoft\Powershell PSI Cmdlets for Project Server 2010\ProjectPSICmdlets.dll"
$assem = [System.Reflection.Assembly]::LoadFile($path)
import-module -assembly $assem
$url = "http://pwaurl/pwa";
$dataset = New-Object System.Data.DataSet
$dataset = psi-ReadProjectList $url;
foreach ($p $projName in $projectList)
{
if ($p.PROJ_NAME -eq "MyTestProject")
{
$projectUid = $p.PROJ_UID;
"Publishing project guid = " + $projectUid
$sessionUid = [System.Guid]::NewGuid();
psi-CheckOutProject $url $projectUid $sessionUid "PS Check out"
$jobUid = [System.Guid]::NewGuid()
psi-QueuePublish $url $jobUid $projectUid $true
$jobUid = [System.Guid]::NewGuid()
psi-QueueCheckInProject $url $jobUid $projectUid $true $sessionUid "PS Check In"
}
}
$path = "c:\program files (x86)\Microsoft\Powershell PSI Cmdlets for Project Server 2010\ProjectPSICmdlets.dll"
$assem = [System.Reflection.Assembly]::LoadFile($path)
import-module -assembly $assem
$url = "http://pwaurl/pwa";
$dataset = New-Object System.Data.DataSet
$dataset = psi-ReadProjectList $url;
foreach ($p $projName in $projectList)
{
if ($p.PROJ_NAME -eq "MyTestProject")
{
$projectUid = $p.PROJ_UID;
"Publishing project guid = " + $projectUid
$sessionUid = [System.Guid]::NewGuid();
psi-CheckOutProject $url $projectUid $sessionUid "PS Check out"
$jobUid = [System.Guid]::NewGuid()
psi-QueuePublish $url $jobUid $projectUid $true
$jobUid = [System.Guid]::NewGuid()
psi-QueueCheckInProject $url $jobUid $projectUid $true $sessionUid "PS Check In"
}
}
No comments:
Post a Comment