編集::::現在の問題の状態については、一番下を参照してください。
現在の設定では、バッチファイルは次のようにPowerShellスクリプトを呼び出します
powershell D:\path\powershellScript.v32.ps1 arg1 arg2 arg3 arg4
これを別のPowerShellを呼び出すPowerShellスクリプトに変換したいと思います。ただし、開始プロセスの使用に問題があります。これは私が現在持っているものですが、実行すると次のようになります
No application is associated with the specified file for this operation
これは実行中のPowerShellです
$powershellDeployment = "D:\path\powershellScript.v32.ps1"
$powershellArguments = "arg1 arg2 arg3 arg4"
Start-Process $powershellDeployment -ArgumentList $powershellArguements -verb runas -Wait
編集::::::
以下の助けにより、私は今、次のものを持っています
$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\deploy.code.ps1", "arg1", "arg2", "arg3", "arg4"
Start-Process "powershell.exe" -credential $cred -ArgumentList $powershellArguments
ただし、リモートマシンからこのスクリプトを実行すると、使用されているユーザー名にマシンへの完全な管理者アクセス権がある場合でも、「アクセス拒否」エラーが発生します。