none
powershell commands RRS feed

  • Question

  • Hi,

    I'm trying to create a powershell script that gets the WIndows Updates history. So I researched and found out the command 'Get-WUHistory' but every time I run this command it shows me an error message saying cmdlet is not recognized. 

    So I assumed I may need to install and import those modules, so my command goes

         Install-Module -Name PSWindowsUpdate

         Import-Module PSWindowsUpdate but right after I typed this command, showed me another error message saying 'cannot be loaded because running scripts on this system is disabled. 

    So I typed in Set-ExecutionPolicy RemoteSigned and it worked, so now my sequence of command is:

    1. Set-ExecutionPolicy RemoteSigned

    2. Install-Module -Name PSWindowsUpdate

    3. Import-module PSWindowsUpdate

    4. Get-WUHistory then this command worked

    So I went ahead and create a .ps1 file which contains the following commands

    Set-ExecutionPolicy RemoteSigned;

    Install-Module -Name PSWindowsUpdate;

    Import-module PSWindowsUpdate;

    Get-WUHistory;

    But it doesn't work, I load this through Powershell ISE and on the first it already showed me an error message saying 'running scripts is disabled on this system. Seems like the first line is not running. I opened up Powershell ISE with admin rights.

    Thanks

    TECH-JEFF

    Thursday, October 31, 2019 2:08 AM

All replies

  • Talk t you system administrator. This has been disabled in Group policy.

    You can also try starting posershell with "Bypass"

    powershell -bypass script.ps1


    \_(ツ)_/

    Thursday, October 31, 2019 2:27 AM