PowerShell / PowerShell/PSResourceGet

Uninstall dependent module fails even when newer version is available

Open
#1,922 2 comments 1 reaction 3 assignees View on GitHub

@SydneyhSmith is already working on this.

Since Sep 1, 2026.

  • #2021 by @copilot-swe-agent — open
Area-Uninstall Issue-Bug Needs-Attention :wave:
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.