Skip to content

Uninstall dependent module fails even when newer version is available #1922

@ildjarnisdead

Description

@ildjarnisdead

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

Installed modules:

  • dbatools 2.7.13, which has a dependency requirement for dbatools.library with minversion = 2025.11.29.0, no max version
  • dbatools.library 2025.11.29 and 2025.12.4

Trying to uninstall dbatools.library version 2025.11.29 fails with a dependency check, even though a newer version is installed.

Expected behavior

The dependent module version is uninstalled because a newer version is installed which also fulfills the dependency requirement

Actual behavior

Get-PSResource dbatools* -Scope AllUsers

Name             Version    Prerelease Repository Description
----             -------    ---------- ---------- -----------
dbatools         2.7.13                PSGallery  The community module that enables SQL Server Pros to automate database development and server administration
dbatools.library 2025.12.4             PSGallery  The library that powers dbatools, the community module for SQL Server Pros
dbatools.library 2025.11.29            PSGallery  The library that powers dbatools, the community module for SQL Server Pros

Uninstall-PSResource -Name dbatools.library -Version 2025.11.29 -Scope AllUsers
Uninstall-PSResource: Cannot uninstall version '2025.11.29' of 'dbatools.library'. This package is a dependency for: 'dbatools, dbatools'. If you would still like to uninstall, re-run the command with -SkipDependencyCheck.

Error details

get-error

Exception             :
    Type        : System.Management.Automation.PSInvalidOperationException
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Cannot uninstall version '2025.11.29' of 'dbatools.library'. This package is a dependency for: 'dbatools, dbatools'. If you would still like to uninstall, re-run the command with -SkipDependencyCheck.
            HResult : -2146233087
        CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : InvalidOperation
    Message     : Cannot uninstall version '2025.11.29' of 'dbatools.library'. This package is a dependency for: 'dbatools, dbatools'. If you would still like to uninstall, re-run the command with -SkipDependencyCheck.
    HResult     : -2146233079
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.UninstallPSResource
CategoryInfo          : InvalidOperation: (Microsoft.PowerShel…UninstallPSResource:UninstallPSResource) [Uninstall-PSResource], PSInvalidOperationException
FullyQualifiedErrorId : UninstallPSResourcePackageIsADependency,Microsoft.PowerShell.PSResourceGet.Cmdlets.UninstallPSResource
InvocationInfo        :
    MyCommand        : Uninstall-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 5
    Line             : Uninstall-PSResource -Name dbatools.library -Version 2025.11.29 -Scope AllUsers
    Statement        : Uninstall-PSResource -Name dbatools.library -Version 2025.11.29 -Scope AllUsers
    PositionMessage  : At line:1 char:1
                       + Uninstall-PSResource -Name dbatools.library -Version 2025.11.29 -Scop …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Uninstall-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
      0
      1

Environment data

Get-Module Microsoft.PowerShell.PSResourceGet; $PSVersionTable

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     1.1.1                 Microsoft.PowerShell.PSResourceGet  {Compress-PSResource, Find-PSResource, Get-InstalledPSResource, Get-PSResourceRepository…}

Key   : PSVersion
Value : 7.5.4
Name  : PSVersion


Key   : PSEdition
Value : Core
Name  : PSEdition


Key   : GitCommitId
Value : 7.5.4
Name  : GitCommitId


Key   : OS
Value : Microsoft Windows 10.0.20348
Name  : OS


Key   : Platform
Value : Win32NT
Name  : Platform


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name  : PSCompatibleVersions


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions