none
Question regarding PowerShell script to Uninstall security updates in Windows 7/8 RRS feed

  • Question

  • Hello Everyone,

    I came across a great link on the Scriptcenter   https://gallery.technet.microsoft.com/scriptcenter/Uninstall-security-update-76f2dcb7  which has a PowerShell download that enables you to remove Microsoft updates from computers.  When I download the zip files ->extract it,  I have a file called " UninstallHotFix.psm1 ".   So far so good.  But where I am totally lost is in the directions to use this file. 

    Specifically: 

    Method 1:

    1. Download the script and open the script file together with Notepad or any other script editor.
    2. Scroll down to the end of the script file, and then add the example command which you want to run.
    3. Save the file then run the script in PowerShell

    I assume (1) refers to right clicking on "UninstallHotFix.psm1" and opening it with notepad?

    If I want to run the following...    Uninstall-OSCHotfix -HotFixID KB2830290   do I just paste it at the end of notepad?

    Do I save the file and attempt to run in powershell as a .psm1 file - or as a .ps1  file?

    Lost in Space....

    Adrian

    Thursday, March 12, 2015 10:44 PM

Answers

  • Run $env:PSModulePath -split ';' to see where PowerShell looks for modules (.psm1) by default. If you're using Windows 8.1 or 2012 use C:\Program Files\WindowsPowerShell\Modules -- it'll be listed. If you're using something that does have this path included, then it would probably be best to use the path in your profile (C:\Users\yourusername\...).

    Once you've decided what path to use, create a folder in that path called UninstallHotFix. Then, copy/move the file into the folder. Make sure it has the name UninstallHotFix.psm1, as the file and folder must have the same name. Once that's done, close your PowerShell session and start a new one. At that point, the module and its function(s) should be available for use.

    • Edited by tommymaynard Friday, March 13, 2015 12:12 AM
    • Proposed as answer by Mike Laughlin Friday, March 13, 2015 12:40 AM
    • Marked as answer by Adrian.Roe Friday, March 13, 2015 5:16 PM
    Friday, March 13, 2015 12:11 AM
  • Hi Adrian,

    If the above doesn't help, I recommend posting questions about this item on the QandA tab of the script module:

    https://gallery.technet.microsoft.com/scriptcenter/Uninstall-security-update-76f2dcb7/view/Discussions#content

    I'd recommend following the steps in Method 2 on the gallery item. As an overview:

    1. Save the zip file into C:\Temp

    2. Extract the zip to C:\Temp\UninstallHotFix(PowerShell)

    3. Open a PS console and type the following:


    Import-Module 'C:\Temp\UninstallHotFix(PowerShell)\UninstallHotFix(PowerShell)\UninstallHotFix.psm1'


    You can verify that the module has been loaded by running Get-Module:

    PS C:\> Get-Module
    
    ModuleType Version    Name                                ExportedCommands
    ---------- -------    ----                                ----------------
    Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint
    Script     0.0        UninstallHotFix                     {Uninstall-OSCHotfix, UninstallHotFix}


    Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)

    • Proposed as answer by jrv Friday, March 13, 2015 12:44 AM
    • Marked as answer by Adrian.Roe Friday, March 13, 2015 5:25 PM
    Friday, March 13, 2015 12:40 AM

All replies

  • Run $env:PSModulePath -split ';' to see where PowerShell looks for modules (.psm1) by default. If you're using Windows 8.1 or 2012 use C:\Program Files\WindowsPowerShell\Modules -- it'll be listed. If you're using something that does have this path included, then it would probably be best to use the path in your profile (C:\Users\yourusername\...).

    Once you've decided what path to use, create a folder in that path called UninstallHotFix. Then, copy/move the file into the folder. Make sure it has the name UninstallHotFix.psm1, as the file and folder must have the same name. Once that's done, close your PowerShell session and start a new one. At that point, the module and its function(s) should be available for use.

    • Edited by tommymaynard Friday, March 13, 2015 12:12 AM
    • Proposed as answer by Mike Laughlin Friday, March 13, 2015 12:40 AM
    • Marked as answer by Adrian.Roe Friday, March 13, 2015 5:16 PM
    Friday, March 13, 2015 12:11 AM
  • No need to close session. PowerShell detects new modules immediately.

    ¯\_(ツ)_/¯

    • Proposed as answer by Mike Laughlin Friday, March 13, 2015 12:40 AM
    Friday, March 13, 2015 12:19 AM
  • Hi Adrian,

    If the above doesn't help, I recommend posting questions about this item on the QandA tab of the script module:

    https://gallery.technet.microsoft.com/scriptcenter/Uninstall-security-update-76f2dcb7/view/Discussions#content

    I'd recommend following the steps in Method 2 on the gallery item. As an overview:

    1. Save the zip file into C:\Temp

    2. Extract the zip to C:\Temp\UninstallHotFix(PowerShell)

    3. Open a PS console and type the following:


    Import-Module 'C:\Temp\UninstallHotFix(PowerShell)\UninstallHotFix(PowerShell)\UninstallHotFix.psm1'


    You can verify that the module has been loaded by running Get-Module:

    PS C:\> Get-Module
    
    ModuleType Version    Name                                ExportedCommands
    ---------- -------    ----                                ----------------
    Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint
    Script     0.0        UninstallHotFix                     {Uninstall-OSCHotfix, UninstallHotFix}


    Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)

    • Proposed as answer by jrv Friday, March 13, 2015 12:44 AM
    • Marked as answer by Adrian.Roe Friday, March 13, 2015 5:25 PM
    Friday, March 13, 2015 12:40 AM
  • Now I wonder ... http://tech-comments.blogspot.com/


    ¯\_(ツ)_/¯

    Friday, March 13, 2015 12:45 AM
  • No need to close session. PowerShell detects new modules immediately.

    ¯\_(ツ)_/¯


    Look at that, you're absolutely correct -- thanks, jrv.
    Friday, March 13, 2015 12:49 AM
  • No need to close session. PowerShell detects new modules immediately.


    ¯\_(ツ)_/¯


    Look at that, you're absolutely correct -- thanks, jrv.

    One reason PowerShell is so cool is that it is so dynamic.  Not at al like Internet Explorer.


    ¯\_(ツ)_/¯

    Friday, March 13, 2015 12:55 AM
  • Hi Tommy -

    Used some of what you explained.  Totally indebt - I'm on the right path

    Friday, March 13, 2015 5:24 PM
  • Thank You jrv !!    I am totally on the right path now!  Again -> Thanks!!!
    Friday, March 13, 2015 5:25 PM