Skip to content

Instantly share code, notes, and snippets.

@pstakuu
Created July 7, 2022 21:53
Show Gist options
  • Select an option

  • Save pstakuu/d5dfe659555dd4af8c53c4acf4fffffe to your computer and use it in GitHub Desktop.

Select an option

Save pstakuu/d5dfe659555dd4af8c53c4acf4fffffe to your computer and use it in GitHub Desktop.
Windows Updates and AV
#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