Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 对话框没有弹出_Powershell - Fatal编程技术网

Powershell 对话框没有弹出

Powershell 对话框没有弹出,powershell,Powershell,我正在编写一个脚本,我得到了确认弹出框的帮助,问题是它没有在正确的条件下弹出(带有/sources/install3.swm的USB驱动器) 下面是我的全部代码(因为“是”条件表示执行代码的其余部分)。没有弹出的问题代码是出厂密钥检查: #1。复制wim # 2. 安装wim # 3. 递归地从驱动程序路径注入所有驱动程序 # 4. 提交并卸载wim Param( #传统路径:$DriverPath=“\\desmo\release\ArubaImages\Daily\developer\u t

我正在编写一个脚本,我得到了确认弹出框的帮助,问题是它没有在正确的条件下弹出(带有/sources/install3.swm的USB驱动器)

下面是我的全部代码(因为“是”条件表示执行代码的其余部分)。没有弹出的问题代码是出厂密钥检查:

#1。复制wim
# 2. 安装wim
# 3. 递归地从驱动程序路径注入所有驱动程序
# 4. 提交并卸载wim
Param(
#传统路径:$DriverPath=“\\desmo\release\ArubaImages\Daily\developer\u teamos\master\2.4047.0\Image\Support”
#工厂路径:
[string]$DriverPath=“\\desmo\release\ArubaImages\Factory\customer\master\4.4074.0\Support\13.IMAGE”
)
#检查本地计算机中是否插入了USB驱动器。
做{
$USB=gwmi win32\U磁盘驱动器|
?{$\接口类型-eq“USB”}|
%{gwmi-Query“与{Win32\U DiskDrive.DeviceID=`“$($\.DeviceID.Replace('\','\\'))`}的关联,其中AssocClass=Win32\U DiskDrive ToDiskPartition”}|
%{gwmi-Query“与{Win32_DiskPartition.DeviceID=`“$($.DeviceID)`}的关联程序,其中AssocClass=Win32_LogicalDiskToPartition”}|
%{$\设备ID}
如果($USB-eq$null){
#写入主机“未检测到USB驱动器,请插入USB驱动器”
#弹出暂停按钮,让用户有时间输入USB密钥
$Shell=新对象-ComObject“WScript.Shell”
$Button=$Shell.Popup(“请插入正确的USB密钥并单击“确定”继续。”,0,“未检测到USB驱动器”,0)
}
}而($USB-eq$null)
#检查本地计算机中是否插入了多个USB驱动器。
做{
如果($USB.Count-gt 1){
#弹出以暂停,以便有时间更正USB密钥
$Shell=新对象-ComObject“WScript.Shell”
$Button=$Shell.Popup(“请确保仅插入正确的密钥。”,0,“检测到多个USB驱动器”,0)
}
$USB2=gwmi win32\U磁盘驱动器|
?{$\接口类型-eq“USB”}|
%{gwmi-Query“与{Win32\U DiskDrive.DeviceID=`“$($\.DeviceID.Replace('\','\\'))`}的关联,其中AssocClass=Win32\U DiskDrive ToDiskPartition”}|
%{gwmi-Query“与{Win32_DiskPartition.DeviceID=`“$($.DeviceID)`}的关联程序,其中AssocClass=Win32_LogicalDiskToPartition”}|
%{$\设备ID}
}而($USB2.Count-gt 1)
#检查这是否是正确的钥匙
做{
if(!(测试路径$USB2\sources\install*.swm)){
#弹出以暂停,以便有时间更正USB密钥
$Shell=新对象-ComObject“WScript.Shell”
$Button=$Shell.Popup(“哦!您输入了错误的密钥。请插入正确的密钥。”,0,“输入了错误的密钥”,0)
}
$USB3=gwmi win32\U磁盘驱动器|
?{$\接口类型-eq“USB”}|
%{gwmi-Query“与{Win32\U DiskDrive.DeviceID=`“$($\.DeviceID.Replace('\','\\'))`}的关联,其中AssocClass=Win32\U DiskDrive ToDiskPartition”}|
%{gwmi-Query“与{Win32_DiskPartition.DeviceID=`“$($.DeviceID)`}的关联程序,其中AssocClass=Win32_LogicalDiskToPartition”}|
%{$\设备ID}
}而(!(测试路径$USB3\sources\install*.swm))
#如果install.wim不在文件夹中,请退出脚本
if(!(测试路径。\install.wim)){
写入警告“install.wim不在源文件夹中!按任意键退出。”
$host.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”)
停止进程-Id$PID#我使用停止进程是因为某种原因“退出”对我不起作用。
}
#工厂钥匙检查
$USB4=gwmi win32\U diskdrive |?{$\.interfacetype-eq“USB”}{gwmi-Query”关联{win32\U diskdrive.DeviceID=``($$$\.DeviceID.replace('\','\')`}其中AssocClass=win32\U DiskDriveToDiskPartition'}{win32\U DiskPartition.DeviceID=`($\'\'\''\''),'\'\'\'')`}关联{gwmi-Query”关联{win32\DiskPartition DeviceID=`($$($.DeviceID'\\\''''\\\\\\''''}其中AssocClass=win32 Associator{$\设备ID}
#您需要使用System.Windows.MessageBox
添加类型-AssemblyName“PresentationFramework”
#默认情况下,您不会损坏USB驱动器
$continue='No'
#如果看到该文件,请提示用户
if($(测试路径-路径“$USB4\sources\install3.swm”)){
$caption=“***这似乎是工厂密钥***”
$message=“您确定要继续吗:”
$continue=[System.Windows.MessageBox]::Show($message,$caption,'YesNo');
}
如果($继续-等式“是”){
#用户对“是否提示”说“是”
#继续使用正则脚本
$tempDir=“.\”
#写入主机“临时目录:”,$tempDir
$copiedWimPath=(连接路径$tempDir“install.wim”)
#写入主机“USB密钥不再假定为D:,它可以是任何字母-但计算机中有多个USB密钥会混淆此脚本。当前连接的USB密钥是/是($USB)”-前底色红色-后底色白色
#Write Host“在分割图像文件之前,您可以更正任何USB密钥问题(删除/更改)”,$copiedWimPath-ForegroundColor红色-BackgroundColor白色
#写入主机“临时目录:”,$tempDir
$mountDir=(连接路径“C:\mountForwardWim”“mount”)
#创建挂载目录
新项目-ItemType目录-Path$mountDir-ErrorAction SilentlyContinue
#维姆山
写入主机“将映像装载到”,$mountDir
Mount WindowsImage-路径$mountDir-图像路径$copiedWimPath-索引1
#注入所有驱动程序
编写主机“注入驱动程序”、$mountDir”-这可能需要一段时间,请耐心等待”
添加WindowsDriver-Path$mountDir-Driver$DriverPath-LogLevel WarningInfo-Recurse
#提交并卸载wim
写入主机“从中卸载映像”,$mountDir
卸载WindowsImage-路径$mountDir-保存
$USB5=gwmi win32\U diskdrive |?{$\.interfacetype-eq“USB”}{gwmi-Query”关联{win32\U diskdrive.DeviceID=``($$\.DeviceID.replace('\','\')`}其中AssocClass=win32\U DiskDriveToDiskPartition'}{win32\U DiskPartition.DeviceID=`($\'\''\'\''),'\\'\'')')`}的关联{gwmi-Query”关联{win32\DiskPartition DeviceID=`($$$\'.DeviceID=win32 Associator