Powershell Script To Run Windows Update Remotely Created

admin
RECOMMENDED: Click here to fix Windows errors and improve PC performance


Ways to Get Windows Update With PowerShell on Windows 10. – PowerShell options have occupied locations on the Win+X menu replacing Command prompt. Microsoft is emphasizing the use of this Command line shell on Windows 10. So let’s learn to use PowerShell to receive the Windows update on Windows 10. Jira vmware appliance antivirus. See a very interesting guide in this concern How to Create Restore Point on Windows 10 Using PowerShell.

This is a security Feature, Windows Update with Powershell Remoting do not work. But here is a work a round: - save your Update Script on a Network Share - create remote on each System a Update Task with the Task sheduler. Save this script to your script folder. I place all scripts in c: admin scripts. Lastly, a scheduled task must to be setup. Create a task that runs as the user created earlier. I set the task to run every 5 minutes, but this can be adjusted per your needs. The program to run is PowerShell and the argument is the Maintain-FirewallRules.ps1 script.

PowerShell, however, was misunderstood to be the replacement for Command Prompt. This is why users did not use PowerShell as much as they use command prompt. There is nothing to be feared of while using the PowerShell. It has a completely different purpose except the inclusion and execution using commands thing in the former.You can update and upgrade your Windows version easily by using the PowerShell.

Launched in 2006, this tool has established itself to be the first choice for the network administrators and advanced users altogether. Not just this, it has even extended its functionality by coming with the Linux versions as well. The Powershell, being a framework, target to achieve configuration management and task automation. It consists of a command shell and a language based on the NET framework.

This article will tell you that how you can get Windows Update With PowerShell. So without wasting more time, let’s get started.

Ways to Get Windows Update With PowerShell in Windows 10

Section 1 – Installation of PowerShell Windows Update Module

Read the steps given below carefully to install this module on your system.

Update

Step 1 – Go to Microsoft TechNet and download the zip file named PSWindowsupdate.zip from there.

Step 2 – Right click on the downloaded file and choose Extract all. This will make a separate folder for its components (file’s).

Step 3 – Select a destination or extract the Zip content (archive) to C: > Windows > System32 > WindowsPowerShell > v1.0 > Modules

Powershell Script To Run Windows Update Remotely Created Check

Step 4 – After clicking extract, click on Continue on the Destination Folder Access Denied pop up.

Step 5 –Open elevated PowerShell (as an admin) and change the policy from Restricted to RemoteSigned. Just type in the following cmdlet:

Set-ExecutionPolicy RemoteSigned

Enter Y to accept the above-mentioned command. This will allow you to run scripts of PowerShell from any unknown publisher as well.

Step 6 - Import the PSWindowsUpdate module with the following command:

Import-Module PSWindowsUpdate

Step 7 – You can also get a complete list of all cmdlets for PSWindowsUpdate through the following command:

Get-Command-Module PSWindowsUpdate

Section 2 – Add Support for other products (Optional)

Step 1 – Go to the Settings app > update & Security > Windows Update > Advanced Optionsto change your preferences if you wish to receive updates to other Microsoft products while updating your Windows.

Enable the same facility in PSWindowsUpdate using the following command:

Add-WUServiceManager-ServiceID 7971f918-a847-4430-9279-4a52d1efe18d

Type Y to accept the command and entering it for execution

Section 3 – Check, Install or hide Windows Update with PowerShell anytime

Step 1 – To obtain the list of all the updates, type the following cmdlet:

Get-WUInstall-MicrosoftUpdate-ListOnly

Step 2 – To obtain/ check updates and feature upgrades that are available for Windows, type the following cmdlet.

Get-WUInstall-ListOnly

Step 3 – Simply filter the updates with the full or partial title of an update to hide it from the list.

Step 4 – Now type – Hide-WUUpdate-Title “Microsoft*”-Confirm: $ False

This command will hide all the updates having the work Microsoft in their title.

Step 5 – You can even hide any update using KB ID instead of using the title. Use the following command:

Hide-WUUpdate-KBArticleID “”KB4013867” –Confirm: $False

To unhide the updates or feature upgrades:

KB ID or using filters or titles can also unhide an update in the list. Use the following cmdlet for this:

Hide-WUUpdate-Title “Microsoft*”-HideStatus: $False-Confirm: $False

To install all updates with manually handling rejection and acceptance requests from each, use the following cmdlet:

Get-WUInstall

To add additional Microsoft updates, use:

Get-WUInstall-MicrosoftUpdate

Step 8 – Enter Y to accept and N to reject each update manually.

Step 9 – Without accepting manually, switch to the automatic mode by adding the parameter Autoboot or AutoAccept to the command to restart the system.

Get-WUInstall-MicrosoftUpdate-AcceptAll-AutoReboot

Step 10 – You can hide or unhide feature upgrades like Windows installer builds as we did for the case of updates (to hide them).

Section 4 – Uninstalling an Update or to Check the Update History

Step 1 – Enter the following command to check the update history anytime:

Get-WUHistory

Step 2 – Uninstall the updates using the following cmdlet:

Get-WUUninstall-KBArticleID “KB4013867”-Confirm: $False

Section 5 – To obtain Help (the final section)

PowerShell help is also available but you need to type certain cmdlets for that. For example, to get help about Hide-WUUpdate, type the following cmdlet.

Get-Help Hide-WUUpdate

Accept the command by entering Y in the prompt. Get-Help has to be updated while running it for the first time. It is no major concern as it is only a one-time process and need not be done again and again.

That’s it; this is how you can easily Get Windows Update With PowerShell in Windows 10 anytime. Type and execute the commands carefully as failing to this can easily build-up errors in the smooth functioning of the system.


RECOMMENDED: Click here to fix Windows errors
Active9 months ago

How do I run a PowerShell script?

  • I have a script named myscript.ps1
  • I have all the necessary frameworks installed
  • I set that execution policy thing
  • I have followed the instructions on this MSDN help pageand am trying to run it like so:powershell.exe 'C:my_pathyada_yadarun_import_script.ps1' (with or without --noexit)

which returns exactly nothing, except that the file name is output.

Powershell Script To Run Windows Update Remotely Created Windows 10

No error, no message, nothing. Oh, when I add -noexit, the same thing happens, but I remain within PowerShell and have to exit manually.

The .ps1 file is supposed to run a program and return the error level dependent on that program's output. But I'm quite sure I'm not even getting there yet.

What am I doing wrong?

Powershell script to run windows update remotely created checksPeter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
Pekka 웃Pekka 웃
368k120 gold badges865 silver badges1025 bronze badges

13 Answers

  1. Launch Windows PowerShell, and wait a moment for the PS command prompt to appear
  2. Navigate to the directory where the script lives

  3. Execute the script:

What am I missing??

Or: you can run the PowerShell script from cmd.exe like this:

according to this blog post here Kamus mahmud yunus offline pdf.

Or you could even run your Powershell script from your C# app :-)

Matthew Lock
8,5217 gold badges68 silver badges112 bronze badges
marc_smarc_s
602k136 gold badges1151 silver badges1288 bronze badges

If you are on PowerShell 2.0 use PowerShell.exe's -File parameter to invoke a script from another environment like cmd.exe e.g.:

Keith HillKeith Hill
151k30 gold badges282 silver badges322 bronze badges

If you want to run a script without modifying the default script execution policy, you can use the bypass switch when launching Windows PowerShell.

Chingiz MusayevChingiz Musayev
2,0741 gold badge10 silver badges6 bronze badges

Type:

powershell -executionpolicy bypass -File .Test.ps1

NOTE: Here Test.ps1 is the PowerShell script.

igr
5,3005 gold badges46 silver badges84 bronze badges
SudheeshSudheesh

I've had the same problem, and I tried and tried.. Finally I used:

And put this line in a batch-file, and this works.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
DennisDennis
1,1031 gold badge13 silver badges36 bronze badges

If you only have PowerShell 1.0, this seems to do the trick well enough:

It pipes the script file to the PowerShell command line.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
AndyMAndyM
2,4995 gold badges32 silver badges44 bronze badges

Pretty easy. Right click the .ps1 file in Windows and in the shell menu click on Run with PowerShell.

Powershell Remotely Check For Updates

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
electronictonicelectronictonic

Using cmd (BAT) file:

If you need run as administrator:

  1. Make a shortcut pointed to the command prompt (I named itAdministrative Command Prompt)
  2. Open the shortcut's properties and go to the Compatibility tab
  3. Under the Privilege Level section, make sure the checkbox next to 'Run this program as an administrator' is checked
Kiquenet

Powershell Install Updates Remotely

Kiquenet
7,43428 gold badges111 silver badges207 bronze badges

An easy way is to use PowerShell ISE, open script, run and invoke your script, function..

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
Jose Evaristo Cepeda BarreraJose Evaristo Cepeda Barrera
  • Give the path of the script, that is, path setting by cmd:

    $> . c:program fileprog.ps1

  • Run the entry point function of PowerShell:

    For example, $> add or entry_func or main

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
pkmpkm

If your script is named with the .ps1 extension and you're in a PowerShell window, you just run ./myscript.ps1 (assuming the file is in your working directory).

This is true for me anyway on Windows 10 with PowerShell version 5.1 anyway, and I don't think I've done anything to make it possible.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
rainabbarainabba

In case you want to run a PowerShell script with Windows Task Scheduler, please follow the steps below:

  1. Create a task

  2. Set Program/Script to Powershell.exe

  3. Set Arguments to -File 'C:xxx.ps1'

It's from another answer, How do I execute a PowerShell script automatically using Windows task scheduler?.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
GearonGearon
5,3473 gold badges22 silver badges41 bronze badges

Use the -File parameter in front of the filename. The quotes make PowerShell think it is a string of commands.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
EngineerEngineer

protected by Josh CrozierMar 2 '17 at 18:44

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged windowspowershellscripting or ask your own question.