動機:
Project Server Architectureで読み取れるように
PSI の Web サービス用の SOAP ベースの ASMX インターフェイスは、Project Server 2013 でも引き続き使用できますが、非推奨です。
そのまま
Project Server との対話に使用する PowerShell クライアント スニペットがいくつかあります。サーバーと通信する標準的な方法は、PSI ASMX Web サービスです。
することが
PSI WCF Web サービスを使用する標準にスニペットをリファクタリングしたいと思います。
結果
たとえば、次の単純なコードは正常に機能します。
$Passwd = Get-Content $home\Documents\Password.txt | ConvertTo-SecureString
$Credential = New-Object -typename System.Management.Automation.PsCredential -argumentlist "user_name",$Passwd
$PWAUrl = "http://project_server_name/PWA"
$ProjSvcURL = $PWAUrl + "/_vti_bin/PSI/Project.asmx?wsdl"
$ProjSvcProxy = New-WebServiceProxy -uri $ProjSvcURL -credential $Credential
$projDataSet = $ProjSvcProxy.ReadProjectList()
$projDataSet.Tables[0].Rows.Count
しかし、単純な変換:
$Passwd = Get-Content $home\Documents\Password.txt | ConvertTo-SecureString
$Credential = New-Object -typename System.Management.Automation.PsCredential -argumentlist "user_name",$Passwd
$PWAUrl = "http://project_server_name/PWA"
$ProjSvcURL = $PWAUrl + "/_vti_bin/PSI/ProjectServer.svc"
...
次のメッセージで失敗します。
New-WebServiceProxy : HTTP ステータス 400 で要求が失敗しました: 要求が正しくありません。
IIS ログの抜粋は次のとおりです。
2014-01-05 13:50:41 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(互換;+MSIE+6.0;+MS+Web +サービス+クライアント+プロトコル+2.0.50727.5472) 401 1 2148074254 125
2014-01-05 13:50:41 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(互換;+MSIE+6.0;+MS+Web +サービス+クライアント+プロトコル+2.0.50727.5472) 401 2 5 328
2014-01-05 13:50:41 10.15.43.7 GET /_vti_bin/PSI/ProjectServer.svc/ntlm - 80 ユーザー名 XXX.XXX.XXX.XXX Mozilla/4.0+(互換;+MSIE+6.0;+MS+Web +サービス+クライアント+プロトコル+2.0.50727.5472) 400 0 0 140
2014-01-05 17:58:33 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(互換;+MSIE+6.0;+MS+Web +サービス+クライアント+プロトコル+2.0.50727.5472) 401 2 5 312
2014-01-05 17:58:33 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(互換;+MSIE+6.0;+MS+Web +サービス+クライアント+プロトコル+2.0.50727.5472) 401 1 2148074254 156
2014-01-05 17:58:33 10.15.43.7 GET /_vti_bin/PSI/ProjectServer.svc/ntlm - 80 ユーザー名 XXX.XXX.XXX.XXX Mozilla/4.0+(互換;+MSIE+6.0;+MS+Web +サービス+クライアント+プロトコル+2.0.50727.5472) 400 0 0 109
PowerShell で WCF PSI を使用した例が見つからないのは興味深いことです。誰かがこれをやろうとしたことがありますか?成功した人いますか?誰でもスニペットを公開できますか?