Powershell - 获取OS版本信息和catpion信息

Environment  获取 OSversion:

$OSVersion = [System.Environment]::OSVersion.Version

WMI获取Caption:

$OSCaption = (Get-WmiObject -class Win32_OperatingSystem).Caption

版本转换获取小版本号[Version]:

$IsWindowsServer2012Env = ([version]$scriptargs.OSVersion).Major -eq 6 -and ([version]$scriptargs.OSVersion).Minor -eq 2 -and $scriptargs.OSCaption -like "*Windows Server 2012 *"

判断hotfix是否安排:

$IsHotfix2896660InstalledEnv =(Get-HotFix | Where-Object{$_.HotFixID -eq "KB2896660"}) -ne $null

posted @ 2013-11-21 17:36  Binyao  阅读(1236)  评论(0编辑  收藏  举报