Powershell开始流程与Splatting

问题描述 投票:1回答:1

我想从带有参数的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

你能帮我帮忙吗?

谢谢!

powershell
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.