我正在制作一个带有按钮的提示窗口。该脚本运行并打开一个首选的选择框,但是当我尝试使用 serviceui.exe 在 winpe 中使用相同的方法时,它会将选择保留在 PS 窗口中。
我不确定我是否使用了适当的会话,这可能是下面给出的图像与 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