{"id":2032,"date":"2022-06-04T11:00:48","date_gmt":"2022-06-04T15:00:48","guid":{"rendered":"https:\/\/increasec.com\/?p=2032"},"modified":"2024-12-14T13:14:11","modified_gmt":"2024-12-14T18:14:11","slug":"windows-updates-via-powershell","status":"publish","type":"post","link":"https:\/\/increasec.com\/?p=2032","title":{"rendered":"Windows Updates via Powershell"},"content":{"rendered":"\n<p>From Local PC:<\/p>\n\n\n\n<p>Powershell<br>Install-Module PSWindowsUpdate<br>set-executionpolicy remotesigned<br>Get-WindowsUpdate -verbose -AcceptAll -Install<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Remote PC:<\/p>\n\n\n\n<p>PS C:\\share&gt; $RemoteServer = &#8220;wtf005.wtf.local&#8221;<br>PS C:\\share&gt; Get-WindowsUpdate -verbose -computer $RemoteServer -AcceptAll -Install<br>VERBOSE: wtf005.wtf.local (7\/14\/2022 3:26:58 PM): Connecting to Microsoft Update server. Please wait\u2026<br>VERBOSE: Found [19] Updates in pre search criteria<br>VERBOSE: Found [19] Updates in post search criteria<\/p>\n\n\n\n<p>X ComputerName Result KB Size Title<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&#8212;&#8212;&#8212;&#8212; &#8212;&#8212; &#8212; &#8212;- &#8212;&#8211;<br>1 wtf005.wt\u2026 Accepted KB4484104 287KB Update for Microsoft Office 2016 (KB4484104) 32-Bit Edition<br>1 wtf005.wt\u2026 Accepted KB5002208 129MB Security Update for Microsoft Excel 2016 (KB5002208) 32-Bit Edition<br>1 wtf005.wt\u2026 Accepted KB5002192 1MB Update for Microsoft Office 2016 (KB5002192) 32-Bit Edition<br>1 wtf005.wt\u2026 Accepted KB5002226 3MB Update for Microsoft Office 2016 (KB5002226) 32-Bit Edition<br>1 wtf005.wt\u2026 Accepted KB5002112 1MB Security Update for Microsoft Office 2016 (KB5002112) 32-Bit Edition<br>1 wtf005.wt\u2026 Accepted KB890830 39MB Windows Malicious Software Removal Tool x64 &#8211; v5.103 (KB890830)<br>1 wtf005.wt\u2026 Accepted 22KB Acer Incorporated &#8211; Display &#8211; Acer LCD Monitor V223W<br>1 wtf005.wt\u2026 Accepted 58KB INTEL &#8211; System &#8211; 10\/3\/2016 12:00:00 AM &#8211; 10.1.1.38<br>1 wtf005.wt\u2026 Accepted 58KB INTEL &#8211; System &#8211; 10\/3\/2016 12:00:00 AM &#8211; 10.1.1.38<br>1 wtf005.wt\u2026 Accepted 59KB Intel &#8211; Other hardware &#8211; Intel(R) 200 Series Chipset Family LPC Controlle\u2026<br>1 wtf005.wt\u2026 Accepted 10MB HP Inc. &#8211; Printer &#8211; HP Printer (BIDI)<br>1 wtf005.wt\u2026 Accepted 23KB INTEL &#8211; System &#8211; 7\/18\/1968 12:00:00 AM &#8211; 10.1.14.7<br>1 wtf005.wt\u2026 Accepted 25KB INTEL &#8211; System &#8211; 7\/18\/1968 12:00:00 AM &#8211; 10.1.11.4<br>1 wtf005.wt\u2026 Accepted 8MB Hewlett-Packard &#8211; USB &#8211; 4\/8\/2019 12:00:00 AM &#8211; 1.0.0.237<br>1 wtf005.wt\u2026 Accepted 8MB Hewlett-Packard &#8211; USB &#8211; 4\/8\/2019 12:00:00 AM &#8211; 1.0.0.237<br>1 wtf005.wt\u2026 Accepted 2MB Intel &#8211; SoftwareComponent &#8211; 2130.1.15.0<br>1 wtf005.wt\u2026 Accepted 369MB Intel Corporation &#8211; Display &#8211; 30.0.100.9805<br>1 wtf005.wt\u2026 Accepted KB4023057 3MB 2022-04 Update for Windows 10 Version 21H2 for x64-based Systems (KB4023057)<br>1 wtf005.wt\u2026 Accepted KB5014699 104GB 2022-06 Cumulative Update for Windows 10 Version 21H2 for x64-based Syste\u2026<br>VERBOSE: Accepted [19] Updates ready to Download<br>VERBOSE: Invoke-WUJob: PSWindowsUpdate wtf005.wtf.local (Now):<br>VERBOSE: powershell.exe -Command &#8220;Get-WindowsUpdate -AcceptAll -Criteria \\&#8221;(UpdateID =<br>&#8217;08f46368-f8bd-4293-aa67-6b1e89c86f48&#8242; and RevisionNumber = 201) or (UpdateID = &#8216;e9145472-eaf2-43dd-98c4-727c386d354c&#8217;<br>and RevisionNumber = 201) or (UpdateID = &#8216;5f4faec2-97ad-453a-a5a8-4dbc4cd16eca&#8217; and RevisionNumber = 200) or (UpdateID<br>= &#8216;7da04759-a9db-4b5e-b271-b62f50b98d75&#8217; and RevisionNumber = 200) or (UpdateID =<br>&#8216;2b08f389-09d3-407e-8571-7065f3aeed4b&#8217; and RevisionNumber = 201) or (UpdateID = &#8216;675d532b-cdd5-4f87-a918-72af430c86a9&#8217;<br>and RevisionNumber = 200) or (UpdateID = &#8216;ba902f35-ebe5-4fff-b53d-f45e480726d6&#8217; and RevisionNumber = 2) or (UpdateID =<br>&#8216;a99df3cf-6589-43c1-b435-71a8b7b086c8&#8217; and RevisionNumber = 2) or (UpdateID = &#8216;b8859379-58f5-4bf0-bb56-47283aa80d55&#8217;<br>and RevisionNumber = 3) or (UpdateID = &#8216;9b7fd4ce-aa58-4a53-9f69-c2cae6dc95e6&#8217; and RevisionNumber = 2) or (UpdateID =<br>&#8216;3f6ba9a7-b031-4990-808f-69a9e1ef6a91&#8217; and RevisionNumber = 2) or (UpdateID = &#8216;557c4d28-8e6f-477c-9a3e-7c0def8db8d8&#8217;<br>and RevisionNumber = 1) or (UpdateID = &#8216;eb068434-050c-4911-b105-0ac97e65f848&#8217; and RevisionNumber = 1) or (UpdateID =<br>&#8217;45c8e9e6-cea0-4a02-8959-9ea5fef85a22&#8242; and RevisionNumber = 1) or (UpdateID = &#8216;4efe8a54-e7cd-4146-a2ff-86f34d9ca5ac&#8217;<br>and RevisionNumber = 1) or (UpdateID = &#8216;97709334-8385-4355-b564-d58f211e48bb&#8217; and RevisionNumber = 1) or (UpdateID =<br>&#8216;b01eaa60-b75b-47e4-9d29-4ba6aa98ce91&#8217; and RevisionNumber = 1) or (UpdateID = &#8216;a329b681-ce8c-431d-99f7-052e2901adcb&#8217;<br>and RevisionNumber = 1) or (UpdateID = &#8216;8285c438-e1f7-454e-8d22-36fbe2630db0&#8217; and RevisionNumber = 1)\\&#8221; -Install<br>-IgnoreReboot -Verbose *>&amp;1 | Out-File $Env:TEMP\\PSWindowsUpdate.log&#8221;<\/li>\n<\/ul>\n\n\n\n<p>PS C:\\share&gt;<\/p>\n\n\n\n<p>error:<br><\/p>\n\n\n\n<p>PS C:\\share&gt; Enter-PSSession $RemoteServer<br>[wtf006.wtf.local]: PS C:\\Users\\team\\Documents&gt; Install-Module PSWindowsUpdate<br>[wtf006.wtf.local]: PS C:\\Users\\team\\Documents&gt; set-executionpolicy remotesigned<br>[wtf006.wtf.local]: PS C:\\Users\\team\\Documents&gt; Enable-WURemoting<br>[wtf006.wtf.local]: PS C:\\Users\\team\\Documents&gt; exit<br>PS C:\\share&gt; Get-WindowsUpdate -verbose -computer $RemoteServer -AcceptAll -Install<br>VERBOSE: wtf006.wtf.local (7\/14\/2022 10:41:45 PM): Connecting to Microsoft Update server. Please wait\u2026<br>VERBOSE: Found [13] Updates in pre search criteria<br>VERBOSE: Found [13] Updates in post search criteria<br>etc<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p>  <blockquote class=\"reddit-embed-bq\" style=\"height:316px\" ><a href=\"https:\/\/www.reddit.com\/r\/PowerShell\/comments\/pcsyu4\/pswindowsupdate_access_denied\/\">PSWindowsUpdate Access Denied<\/a><br> by<a href=\"https:\/\/www.reddit.com\/user\/WDizzle\/\">u\/WDizzle<\/a> in<a href=\"https:\/\/www.reddit.com\/r\/PowerShell\/\">PowerShell<\/a><\/blockquote><script async src=\"https:\/\/embed.reddit.com\/widgets.js\" charset=\"UTF-8\"><\/script><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Old Info:  <\/p>\n\n\n\n<p>Logon to the computer you want to update maybe using<br>Enter-PSSession Computername<\/p>\n\n\n\n<p>Install-Module PSWindowsUpdate<br>Get-WindowsUpdate<br>Install-WindowsUpdate -AcceptAll -AutoReboot<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Harder on Windows 8.1\/ Server 2012r2:<\/p>\n\n\n\n<p>Install Dot Net newest verstion<\/p>\n\n\n\n<p>Make sure secure Protocols are enabled<br>[Net.ServicePointManager]::SecurityProtocol<br>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Install-Module PSWindowsUpdate<br> =Error!<br>Install-Module PowershellGet -Force<br> =Error!<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Set-ItemProperty -Path &#8216;HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft.NetFramework\\v4.0.30319&#8217; -Name &#8216;SchUseStrongCrypto&#8217; -Value &#8216;1&#8217; -Type DWord<\/p>\n\n\n\n<p>Set-ItemProperty -Path &#8216;HKLM:\\SOFTWARE\\Microsoft.NetFramework\\v4.0.30319&#8217; -Name &#8216;SchUseStrongCrypto&#8217; -Value &#8216;1&#8217; -Type DWord<\/p>\n\n\n\n<p>***may require a reboot after changing registry keys<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Import-Module PSWindowsUpdate<\/p>\n\n\n\n<p>if running PowerShell scripts is disabled<\/p>\n\n\n\n<p>set-executionpolicy remotesigned<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Show available updates with the following command:     Note this will include all driver updates as well<\/p>\n\n\n\n<p>Get-WindowsUpdate<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>now Install all updates with <\/p>\n\n\n\n<p>Install-WindowsUpdate -AcceptAll -AutoReboot<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>My objective is to run this on weekends against work PCs, so the AutoReboot won&#8217;t impact anyone.<\/p>\n\n\n\n<p>I may have to set the BIOS of each PC to turn on at 6am so the reboots can finish before users arrive at work.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>After testing I hope to put this script into RunDeck or use Scheduled Tasks and use RunDeck to update the Scheduled Tasks.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Logging:<\/p>\n\n\n\n<p>Start-Transcript -Path Computer.log<br>Write-Host &#8220;everything will end up in Computer.log&#8221;<br>Stop-Transcript<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>more info    https:\/\/adamtheautomator.com\/pswindowsupdate\/<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>if you see this error when using task scheduler you need to use an account that has the &#8220;logon as a batch job&#8221; rights<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>PS C:\\share\\SysInternals&gt; .\/PsExec \\\\$RemoteServer cmd.exe<br>winrm quickconfig<\/p>\n\n\n\n<p>if you get an error regarding an interface set to public:<br><\/p>\n\n\n\n<p>Get-NetConnectionProfile<br>Set-NetConnectionProfile -InterfaceIndex 17 -NetworkCategory Private<\/p>\n","protected":false},"excerpt":{"rendered":"<p>From Local PC: PowershellInstall-Module PSWindowsUpdateset-executionpolicy remotesignedGet-WindowsUpdate -verbose -AcceptAll -Install Remote PC: PS C:\\share&gt; $RemoteServer = &#8220;wtf005.wtf.local&#8221;PS C:\\share&gt; Get-WindowsUpdate -verbose -computer $RemoteServer -AcceptAll -InstallVERBOSE: wtf005.wtf.local (7\/14\/2022 3:26:58 PM): Connecting to Microsoft&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[198],"tags":[121],"class_list":["post-2032","post","type-post","status-publish","format-standard","hentry","category-blueteam","tag-powershell"],"_links":{"self":[{"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts\/2032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2032"}],"version-history":[{"count":16,"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts\/2032\/revisions"}],"predecessor-version":[{"id":3886,"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts\/2032\/revisions\/3886"}],"wp:attachment":[{"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}