2012-07-30 5 views
5

リモートサーバーの特定のフォルダにあるファイルを削除します。私は、PowerShellで次のコマンドを実行:Powershell Invoke-Command Remove-Itemリモートサーバー

Invoke-Command -Computer 'compname1' -ScriptBlock {Remove-Item -$args -force } -ArgumentList 'c:\BizTalkDeployment' 

は、私は次のエラーを取得する:

Cannot find drive. A drive with the name '-c' does not exist. 

C:\ BizTalkDeploymentは、サーバcompname1上の正しいパスです。

誰でも私が間違ったことを説明できますか?

答えて

5

$ argsの - inを削除して、スクリプトを再実行してください。あなたもにスクリプトブロックを変更してみてください:

Remove-Item -Path $args[0] 
+0

クリス、それは大きな助け感謝します。 –

3

ます。また、UNCパスを使用してフォルダを削除できます。

Remove-Item \\compname1\c$\BizTalkDeployment -force 
+0

それは私もそれをやる方法です。 –

関連する問題