コード行を実行しようとすると、次のエラーが発生します
Start-Process : This command cannot be executed due to the error:
Access is denied.
これは実行中のコードです
$username = "domain\username"
$passwordPlainText = "password"
$password = ConvertTo-SecureString "$passwordPlainText" -asplaintext -force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,$password
$powershellArguments = "D:\path\ps.script.ps1", "arg1", "arg2", "arg3", "arg4"
Start-Process "powershell.exe" -credential $cred -ArgumentList $powershellArguments -wait
- このコードは、ローカルで実行すると正常に動作しますが、vbs WMI 経由で呼び出した場合は動作しません
- 両方のコンピューターが同じドメインとアドレス範囲に存在する
- 指定されたユーザー名とパスワードには、両方のマシンで管理者権限があります
- ありとなしの両方を試しましたが、
-wait
どちらも機能しません。ユーザーに特権があるため、そのままにしておくことをお勧めします