我想從具有參數的PowerShell腳本調用「PS App Deployment Toolkit」包(Link)。PowerShell啓動過程與潑濺
提到的「PS應用程序部署工具包」 - 包是一個powershell腳本,我想用參數調用。 (從.ps1調用.ps1)
我想使用splatting作爲參數。
我想等待腳本結束。
我想從腳本中獲取退出代碼。
這裏是我的代碼,這是行不通的:
$PSADToolKitInstallWrapper = "C:\Temp\MyPackage\PS-AppDeploy.ps1"
$PSADToolKitParameters = @{
"DeploymentType" = "Uninstall";
"DeployMode" = "Interactive";
"AllowRebootPassThru" = $True;
"TerminalServerMode" = $False;
"DisableLogging" = $False;
}
$InstallStatus = Start-Process -FilePath "PowerShell.exe" -ArgumentList $PSADToolKitInstallWrapper @PSADToolKitParameters -Wait -PassThru
Write-Host "Exit-Code: $($InstallStatus.ExitCode)"
此線將正常工作,但我想在上面的例子中,設置參數,如:
$InstallStatus = Start-Process -FilePath "PowerShell.exe" -ArgumentList "$PSADToolKitInstallWrapper","-DeploymentType Install -DeployMode Silent -AllowRebootPassThru -TerminalServerMode" -Wait -PassThru
請你幫助我得到這個工作?
謝謝!
這不是在你的例子中濺起。如果你擺脫了'@ PSADToolKitParameters',它將工作 – TheIncorrigible1
...和@InIncorrigible1是正確的。您的示例不包含濺射。查看我的答案,瞭解如何使用濺射。 –