We use some PowerShell modules in a single PowerShell script deployment. Using the following command, we install the module (i.e. XXXX) in "C: \ Program Files \ WindowsPowerShell \ Modules".
Install-Module -Name "XXXX" -AllowClobber -RequiredVersion "XXXX" -Repository "XXXX" -Scope AllUsers
Now that we have used the functionality of this module, we will remove it at the end of the script deployment using the following command.
Remove-Module -Name "XXXX" -force
Uninstall-Module -Name "XXXX" -AllVersions -force
But this uninstall module command gives the following error.
WARNING: The version '
applications.
PackageManagement\Uninstall-Package : Module 'XXXX' is in currently in use.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2046 char:21
+ ... $null = PackageManagement\Uninstall-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Packag
e], Exception
+ FullyQualifiedErrorId : ModuleIsInUse,Uninstall-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.Uninstall
Package
Does anyone have any ideas to solve this?
source
share