我想从带有参数的PowerShell脚本中调用“PS App Deployment Toolkit”-package(Link)。
提到的“PS App Deployment Toolkit”-package是一个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
你能帮我帮忙吗?
谢谢!