特定のユーザーの他のコンピューターでユーザーのWindows環境変数を取得および設定するためのスクリプトがあります。このユーザーのパスワードをハードコーディングして、スクリプトを実行するたびにパスワードを入力する必要がないようにすることはできますか?
私のスクリプトは次のようになります。
$s5 = New-PSSession -computername testauto2, testauto3 -Credential
Domain\testautouser
invoke-command -session $s5[0] -scriptblock {[Environment]::GetEnvironmentVariable("TestBrowser", "user")}