Created
July 7, 2022 21:53
-
-
Save pstakuu/d5dfe659555dd4af8c53c4acf4fffffe to your computer and use it in GitHub Desktop.
Windows Updates and AV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #credits | |
| #https://stackoverflow.com/questions/7330187/how-to-find-the-windows-version-from-the-powershell-command-line | |
| #https://serverfault.com/questions/1035099/getting-full-windows-version-on-batch-or-powershell-like-microsoft-windows-v | |
| function Check-WUAV { | |
| param($servers) | |
| BEGIN{ | |
| $scriptblock = { | |
| $AvInfo = Get-MpComputerStatus | |
| $WuInfo = Get-Hotfix | |
| $subversion = Get-ItemPropertyValue 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion' 'UBR' | |
| $systemInfo = systeminfo /fo csv | ConvertFrom-Csv | select OS*, System*, Hotfix* | |
| return $AvInfo,$WuInfo,$subversion,$systemInfo | |
| } | |
| } | |
| PROCESS{ | |
| foreach ($server in $servers) { | |
| $AvInfo,$WuInfo,$subversion,$systemInfo = Invoke-Command -ScriptBlock $scriptblock -ComputerName $server | |
| $fullVersion = "$($systemInfo.'OS Version' -split '\s' | select -First 1).$($subversion)" | |
| $props = [ordered]@{ | |
| Server = $server | |
| AVSignatureVersion = $AvInfo.AntivirusSignatureVersion | |
| AVSignatureLastUpdated = $AvInfo.AntivirusSignatureLastUpdated | |
| AVEnabled = $AvInfo.AntivirusEnabled | |
| InstalledPatchesObj = $WuInfo | |
| InstalledPatchesStr = ($wuinfo | % {"$($_.hotfixid):$($_.installedon)"}) -join "," | |
| lastBootTime = $systemInfo.'System Boot Time' | |
| OSFullVersion = "$($systemInfo.'OS Version' -split '\s' | select -First 1).$($subversion)" | |
| OSMajorVersion = "$($systemInfo.'OS Version' -split '\s' | select -last 1)" | |
| OSMinorVersion = $subversion | |
| } | |
| New-Object -TypeName PSObject -Property $props | |
| } | |
| } | |
| END{} | |
| } | |
| $servers = "Dc01","DC02" | |
| $res = Check-WUAV -servers $servers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment