$report= [pscustomobject]@{' Date ' =$null; ' MSRC ' =$null; ' KB ' =$null; ' Severity ' =$null; ' Version ' =$null; ' Summary ' =$null; ' Threattype ' =$null}$report| Export-csv-path E:\PatchReport.csv-Force-Encoding Unicode-delimiter"' t"$parttern="[(]\d{7}[)]" #get the right-most KB number of the title, which is common for any year's patches$parttern _title="\b (Information disclosure| Remote Code execution| Elevation of privilege| Security Feature bypass| Cumulative Security update| Security update| Denial of service| Tampering) \b"$WebClient= new-Object System.Net.WebClient$WebClient. Encoding=[system.text.encoding]::UTF8$xml= [XML] ($WebClient. Downloadstring ("Https://technet.microsoft.com/en-us/security/rss/bulletin"))$xml. Rss.channel.item |foreach {$msrc=$_. link.substring ($_. link.length-8, 8) Do {$patchweb=$WebClient. Downloadstring ("https://technet.microsoft.com/en-us/library/security/$msrc")} while(!$?)#$? Indicates whether the result returned by the last command executed is true or FALSE, where true$result= [Regex]::match ($patchweb,$parttern)$kbnumbers=$result. value. Substring (1, 7)#KB$cdata=$_. Encoded. InnerText-replace "Severity Rating:","" -replace "Revision Note:","" -replace "Summary:",""-split"<br/>"#Release date +ms number +KB + Hazard level + version + summary information + threat typeforeach($kbnumber inch $kbnumbers) {$_. pubdate.substring (0,10) +"' t"+ ($_. link). substring ($_. link.length-8, 8) +"' t"+$kbnumber+"' t"+$cdata[0] +"' t"+$cdata[1]. Substring (0,4) +"' t"+$cdata[2] +"' t"+ [Regex]::match ($_. title,$parttern _title, ' IgnoreCase ')} } | Out-file-filepath E:\PatchReport.csv-Append-Encoding Unicode
Get the XML content for RSS and then reshape the output (Windows Patch)