目标:
鉴于:
问题:
已经尝试
$registry = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
Get-ItemProperty -name Version,Release -EA 0 |
Where { $_.PSChildName -match '^(?!S)\p{L}'} |
Select Version
$flag = $false
foreach ($version in $registry){
if ($version.Version -like "4.5*"){
"Found Version " + $version.Version
$flag = $true
break
} else {
}
}
if($flag){
# .NET 4.5* is installed
} else {
# install .NET 4.5.2
& "\\ad1dc01\deployment$\Microsoft\DotNet\452\NDP452-KB2901907-x86-x64-AllOS-ENU.exe" /q /norestart
}
答案 0 :(得分:0)
在系统完成关闭之前,安装程序可能尚未完成。尝试使用-Wait参数的Start-Process cmdlet?
Start-Process -FilePath "\\ad1dc01\deployment$\Microsoft\DotNet\452\NDP452-KB2901907-x86-x64-AllOS-ENU.exe" -ArgumentList "/q /norestart" -Wait