Script to automate MBSA scan and download missing patches
hi,
not powershell guy go easy on me here. found script use. script scans missing patches via ms's mbsa, downloads them , generates batch file install missing ones. issue having command downloads patches doesn't download anything. author of script has closed wrote on site future comment. ideas?
$updatexml = “updates.xml” $tofolder = “c:\temp\” $installfile = $tofolder +”\_install.bat” #initialize webclient downloading files $webclient = new-object net.webclient $webclient.usedefaultcredentials = $true # content of xml file $updates = [xml](get-content $updatexml) “@echo off” | out-file $installfile “rem install patches” | out-file $installfile -append foreach ($check in $updates.xmlout.check) { write-host “checking for”, $check.name write-host $check.advice.tostring() #checking files download foreach ($updatedata in $check.detail.updatedata) { if ($updatedata.isinstalled -eq $false) { write-host “download file kb”, $updatedata.kbid write-host “starting download “, $updatedata.title, “.” $url = [uri]$updatedata.references.downloadurl $filename = $url.segments[$url.segments.count – 1] $tofile = $tofolder +”\”+ $filename #$webclient.downloadfile($url, $tofile) write-host “done downloading” “@echo starting installing “+ $filename | out-file $installfile -append if ($filename.endswith(“.msu”)) { “wusa.exe “+ $filename + ” /quiet /norestart /log:%systemroot%\temp\kb”+$updatedata.kbid+”.log” | out-file $installfile -append } elseif ($filename.endswith(“.cab”)) { “start /wait pkgmgr.exe /ip /m:”+ $filename + ” /quiet /nostart /l:%systemroot%\temp\kb”+$updatedata.kbid+”.log” | out-file $installfile -append } else { $filename + ” /passive /norestart /log %systemroot%\temp\kb”+$updatedata.kbid+”.log” | out-file $installfile -append } “@echo installation returned %errorlevel%” | out-file $installfile -append “@echo.” | out-file $installfile -append write-host } } write-host }
use windows update install updates. mbsa not designed used way. reporting tool.
also site not repairing scripts found on internet.
you might explain why commented out download command.
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment