ChrisTitusTech / website

My HUGO Website that I use for Videos, Blogs, and Redirects
74 stars 44 forks source link

install-windows-update-powershell/ #94

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Install Windows Update Powershell

Having Fun with Technology

https://christitus.com/install-windows-update-powershell/

djevrek commented 1 year ago

If you have error about Executing policies, you can get over it with this command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

hapek86 commented 1 year ago

Hi, I tried first command : Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot | Out-File "C:($env.computername-Get-Date -f yyyy-MM-dd)-MSUpdates.log" -Force and I have got wrong name of log. Are You sure that command starting from "Out-File" is ok? I replace code to : Out-File "C:\$env:COMPUTERNAME-$(Get-Date -f yyyy-MM-dd)-MSUpdates.log" -Force in my console and after that name of log is correct. Correct me if I'm wrong.

athapour84 commented 1 year ago

what to do when thiw error occours?

"Add-WUServiceManager : The 'Add-WUServiceManager' command was found in the module 'PSWindowsUpdate', but the module cou ld not be loaded. For more information, run 'Import-Module PSWindowsUpdate'. At line:1 char:1

darekols commented 1 year ago

@athapour84 use latest version of Powershell

athapour84 commented 1 year ago

Thanks for your reply. But it didn't work, even with the latest version of Powershell.

Zantetsukens-cut commented 1 year ago

so I really like the idea of running updates with PowerShell. but my heart hit the floor when it installed Microsoft compatibly drivers over way better unsigned drivers I fought windows to install. it did this even with the windows update group policy's set. so you wouldn't know of A. a modified command that leaves them out. or B. Know where to get a set of GPO's to control this install method. Now I'm off to go do some damage control. thanks

Vertex21 commented 1 year ago
# Trust the PSGallery repository
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

# Check if the PSWindowsUpdate module is installed
if (!(Get-Module -Name PSWindowsUpdate)) {
    # If the module is not installed, install it using the Install-Module cmdlet
    Install-Module PSWindowsUpdate
}

# Add the Microsoft Update service to the list of available update sources
Add-WUServiceManager -MicrosoftUpdate

# Install all available updates
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot | Out-File "C:\($env.computername-Get-Date -f yyyy-MM-dd)-MSUpdates.log" -Force
talishka commented 1 year ago

Hi! Does it work with WSUS on corporate enviroment with this configuration? Specifically what does this line do? "Add-WUServiceManager -MicrosoftUpdate"

Thanks!

ChrisTitusTech commented 1 year ago

Hi! Does it work with WSUS on corporate enviroment with this configuration? Specifically what does this line do? "Add-WUServiceManager -MicrosoftUpdate"

Thanks!

I'd remove that line for a WSUS implementation. Other than that you should be set.

bpetch44 commented 1 year ago

The correct setting for creating the log file should be: Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot | Out-File "C:\$env:COMPUTERNAME-$(Get-Date -f yyyy-MM-dd)-MSUpdates.log" -Force

jstrat31 commented 1 year ago

Just a heads up, the syntax for the "$Computers" variable is incorrect on the 3rd example. Is should be $Computers = "pc2","pc3","pc4"

Using it the way it was written in the example $Computers = "pc2,pc3,pc4" makes PowerShell think it's a single computer named "pc2,pc3,pc4" rather than multiple computers.

ankkol2011 commented 1 year ago

Have the same issue as @athapour84

what to do when thiw error occours?

"Add-WUServiceManager : The 'Add-WUServiceManager' command was found in the module 'PSWindowsUpdate', but the module cou ld not be loaded. For more information, run 'Import-Module PSWindowsUpdate'. At line:1 char:1

Add-WUServiceManager -MicrosoftUpdate


I've also tried the latest power shell version but still the same issue. Any help would be much appreciated.

gooseboi commented 1 year ago

Hi! I followed the steps from this tutorial on a pretty barebones install created with the MSMG toolkit and whenever I run Get-WindowsUpdate or Install-WindowsUpdate there is no output. When ran with verbose output all Get-WindowsUpdate says is VERBOSE: PCNAME (17/01/2023 20:28:49): Connecting to Windows Update server. Please wait...

All the other commands ran without any problem so I don't know what could be causing the issue. Thanks!

Gizzle830 commented 1 year ago

What's the best way to rip out the windows update service like you did?

hubermarkus commented 1 year ago

Hi, i recommend using www.wuinstall.com its a command line tool and has no requirements