Unable to run a Powershell Script Located on Multiple Remote Servers RRS feed

  • Question

  • it will gives error even after passing Credentials in the script, please see above



    $servers = Get-Content "C:\WindowsUpdate\MT-Servers.txt"
    $cred = get-credential

    $testpath = "C:\WindowsUpdate\Get-WindowsUpdates.ps1"

    foreach ($server in $servers) {

    if (Test-Path -Path $testpath) {

        Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock {powershell.exe C:\WindowsUpdate\Get-WindowsUpdates.ps1 -Install -EulaAccept}
        Write-Host -ForegroundColor Green "installtion Started on $server"
    }else {

       Write-Host -ForegroundColor Red "$server is not online, unable to connect"


    I have also tried giving WMI Permission mentioned in the below link but still no luck:) please assist me how i can fix this stuff.

    I am actually trying to install Windows Updates on Remote Computers using Get-Windows Script





    after giving all the permission if i run the following cmd it gives response, the computer name mentioned in the screenshot below is a remote computer

    • Moved by Bill_Stewart Friday, July 27, 2018 8:24 PM Unanswerable drive-by question
    Monday, May 21, 2018 7:02 PM

All replies

  • DO NOT post pictures of error or code.  Copy the error and post it using the code posting tool provided.

    Windows updates cannot be remotely installed.


    Monday, May 21, 2018 7:11 PM
  • thanks for your response to my post!!

    please let me know whether the method mentioned in the below link works to install win update remotely?


    Even with this function "Invoke-WUInstall" I am not able to run it on Remote server.

    Monday, May 21, 2018 11:14 PM
  • You cannot remotely install updates with any script or other code.  This is not available in Windows.  To install updates you can only schedule an update with WU or with WSUS.

    If an admin path (MSU) is available then that can be installed remotely or from GP.


    Monday, May 21, 2018 11:57 PM