Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Monday, December 12, 2016

Removing and Unwanted PowerShell Module

This evening I’m enjoying my warm hotel room. I’m in Saskatoon, Canada in winter teaching PowerShell so no sight seeing this trip. On the plus side, I’m prepping to teach MOC 20697-2B next week from the comfort of my office in Phoneix.  Naturally, I’m looking over my PowerShell code for the class and making sure there have not been any surprise changes with Azure or my cmdlets from the PSGallery.

I’ve noticed that the module for OneDrive has a version change.  The problem  is, I already installed the new one.

PS C:\> Get-Module -Name OneDrive -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name          ExportedCommands                                                   ---------- -------    ----          ----------------                                                               
Script     1.0.3      OneDrive      {Get-ODAuthentication, Get-ODWebContent, Get-ODDrives... 

Script     0.9.2      OneDrive      {Get-ODAuthentication, Get-ODWebContent, Get-ODDrives...


Fortunately, Uninstall-Module has a parameter called –RequiredVersion.  Just provide it with the version number of the module that you want to remove to prevent you from accidentally removing the newer version.

PS C:\> Uninstall-Module -Name OneDrive -RequiredVersion 0.9.2 -Verbose
VERBOSE: Performing the operation "Uninstall-Module" on target "Version '0.9.2' of module 'OneDrive'".
VERBOSE: Successfully uninstalled the module 'OneDrive' from module base 'C:\Program Files\WindowsPowerShell\Modules\OneDrive\0.9.2'.


Now only one version remains.

PS C:\> Get-Module -Name OneDrive -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                               
---------- -------    ----                                ----------------                                                               
Script     1.0.3      OneDrive                            {Get-ODAuthentication, Get-ODWebContent, Get-ODDrives, Format-ODPathorIDStrin...


No comments: