[X] Make sure you are able to repro it on the latest version
[X] Search the existing issues.
Steps to reproduce
I have a module that is dependent on version 5.4.0 of the Microsoft Teams module.
Uninstalling version 5.3.0 of the Teams module fails, giving a dependency error.
I can uninstall by using the -Force parameter; however that should not be necessary since the older Teams module is outside the dependency scope.
I would expect the Teams module to be uninstalled correctly.
PS> Uninstall-Module -Name MicrosoftTeams -RequiredVersion 5.3.0
PS>
Actual behavior
PS> Uninstall-Module -Name MicrosoftTeams -RequiredVersion 5.3.0
Uninstall-Package: The module 'MicrosoftTeams' of version '5.3.0' in module base folder 'C:\Program Files\PowerShell\Modules\MicrosoftTeams\5.3.0' cannot be uninstalled, because one or more other modules
'MyModule' are dependent on this module. Uninstall the modules that depend on this module before uninstalling module 'MicrosoftTeams'.
Error details
PS> Get-Error
Exception :
Type : System.Exception
Message : The module 'MicrosoftTeams' of version '5.3.0' in module base folder 'C:\Program Files\PowerShell\Modules\MicrosoftTeams\5.3.0' cannot be uninstalled, because one or more other modules
'MyModule' are dependent on this module. Uninstall the modules that depend on this module before uninstalling module 'MicrosoftTeams'.
HResult : -2146233088
TargetObject : Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
CategoryInfo : InvalidOperation: (Microsoft.PowerShel…ts.UninstallPackage:UninstallPackage) [Uninstall-Package], Exception
FullyQualifiedErrorId : UnableToUninstallAsOtherModulesNeedThisModule,Uninstall-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
InvocationInfo :
MyCommand : Uninstall-Package
ScriptLineNumber : 12733
OffsetInLine : 21
HistoryId : 38
ScriptName : C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1
Line : $null = PackageManagement\Uninstall-Package @PSBoundParameters
PositionMessage : At C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:12733 char:21
+ … $null = PackageManagement\Uninstall-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\program files\powershell\7\Modules\PowerShellGet
PSCommandPath : C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1
InvocationName : PackageManagement\Uninstall-Package
CommandOrigin : Internal
ScriptStackTrace : at Uninstall-Module<Process>, C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1: line 12733
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
Environment data
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.7
PSEdition Core
GitCommitId 7.3.7
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
I have a module that is dependent on version 5.4.0 of the Microsoft Teams module. Uninstalling version 5.3.0 of the Teams module fails, giving a dependency error. I can uninstall by using the -Force parameter; however that should not be necessary since the older Teams module is outside the dependency scope.
Some further details:
MyModule.psd1 has the following section:
Expected behavior
Actual behavior
Error details
Environment data
Version
2.2.5
Visuals
No response