0

デスクトップからリモート マシンで作業しており、次のスクリプトがあります。

Invoke-Command -computername $name -authentification default -credential $creds1 -scriptblock {net use \share $password2 /user:otherdomain\otheruser}

次に、指定されたログオン セッションが存在しません。すでに終了している可能性があります。net use \\share $password2 /user:otherdomain\otheruserリモートマシンで直接実行すると完全に機能するため、これはイライラします。回避策はありますか、それとも何か見逃しましたか?

4

1 に答える 1

0

変数をスクリプト ブロックに渡す必要があります$password2。そうしないと、値が空になります。

Invoke-Command -Computer $name ... -ScriptBlock {
  net use \\host\share $args[0] /user:otherdomain\otheruser
} -ArgumentList $password2
于 2013-06-21T18:53:44.500 に答える