WinPE Powershell在PS窗口vs框中提示选择(首选)

时间:2015-02-03 22:55:37

标签: powershell prompt sccm winpe

我正在制作一个带按钮的提示窗口。该脚本运行并打开一个首选的选择框,但是当我尝试使用serviceui.exe在winpe中使用相同的方法时,它会将选择保留在PS窗口中。

enter image description here 我不确定我是否正在使用适当的会话,这可能是为什么下面给出的图像没有显示与PS窗口相比。这段代码可能不正确,因为我一次修补这个问题。我最初的问题是弄清楚如何显示下面的选择框,然后我可以专注于代码,但对所有建议开放!非常感谢您查看它!

缩写代码:

$Title = "Workgroup Machine Destination"
$Info = "Please select the location where this machine will belong:" 
$options = [System.Management.Automation.Host.ChoiceDescription[]] @("&Selection1", "&Selection2", "&Selection3")
[int]$defaultchoice = 0
$opt = $host.UI.PromptForChoice($Title , $Info , $Options,$defaultchoice)
switch($opt)
{
0 { $apw = 'pwd1'}
1 { $apw = 'pwd2'}
2 { $apw = 'pwd3'}
}
$apw = New-Object -COMObject Microsoft.SMS.TSEnvironment 
$apw.Value("OSDLocalAdminPassword") = $apw

我通过cmdline运行的脚本是:

ServiceUI.exe -process:TSProgressUI.exe %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File PCLocation.ps1

0 个答案:

没有答案