2
首次使用powershell,我似乎无法得到下面的工作 - 没有显示 - 我认为脚本工作,但我认为我需要一些东西来显示结果?任何帮助,请:单服务器上的获取修补程序
$hotfix1 = Get-HotFix -Id KB981872
If($hotfix)
{
$Output = "Hotfix is installed you may proceed"
}
else
{
$Output = "Hotfix is not installed"
}
$hotfix1 = Get-HotFix -Id KB981872
由于吉文 - 我已经更新了它:
write-host "This will check if Hotfix KB979808 is installed on this Server." -ForegroundColor
Black -BackgroundColor Cyan
write-host "This is required for Windows Server 2008 R2 DFSR Pre-Seeding Robocopying" -
ForegroundColor Black -BackgroundColor Cyan
Write-Host ""
$hotfix1 = Get-HotFix -Id KB979808 -ErrorAction SilentlyContinue
If($hotfix1 -match "KB979808")
{
Write-Host "Hotfix is installed you may proceed" -foregroundcolor "green"
Write-Host ""
}
else
{
Write-Host "Hotfix is NOT installed - Please ensure you install this hotfix BEFORE"
Write-host "copying any data" -foregroundcolor "red"
Write-Host ""
}
太好了。有一件事,我会改变这一行:'If($ hotfix1 -match“KB979808”)'to'If($ hotfix1.HotFixID -eq'KB979808')',或简单地'If($ hotfix1)...' –