2010-09-24 57 views
0

我想通過使用PSSessionOption的ApplicationArguments屬性將一些參數傳遞到新的Powershell遠程會話。不幸的是,這些論據似乎並沒有出現。Powershell遠程ApplicationArguments不工作

下面的代碼:

$client = "Bubba" 
$options = New-PSSessionOption -ApplicationArguments @{ Client = $client } 

Enter-PSSession -ComputerName "Server" -SessionOption $options 

$clientName = $PSSenderInfo.ApplicationArguments.Client 
$dir = New-Item "c:\temp\$clientName" -type directory 

Exit-PSSession 

這將導致一個錯誤: 「NewNotImplementedException在文件偏移量101:行:列...」

難道我做錯了什麼?

回答

0

顯然Enter-PSSession和Exit-PSSession在腳本中不起作用!它們僅用於交互式命令行使用。這解釋了這個問題。

+0

我在哪裏可以閱讀更多關於這方面的信息? – 2011-11-09 12:32:10