Open peppekerstens opened 5 years ago
@peppekerstens are you having this issue with other modules or just PackageManagement?
Frankly, i did not test this.
I try to move from using the 'modules' command-set to the 'package' command-set in all my code for clarity. And thus, completely depending on PS subsystem to nicely translate this back-and-forth between the 'modules' and the 'package' command-set. (for anyone in my organisation or third-person who still uses the 'modules' command-set)
This has been working fine under PS5 so far.
This issue was triggered when I started fiddling around because of issue https://github.com/OneGet/oneget/issues/461
The PackageManagement module is an obvious example, because it is always present, even on clean PS installs, like PS6 and PS7.
I will do some testing.
So.....installed a vanilla W2019 machine on Azure. And:
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...
Get-Module -Name PackageManagement -ListAvailable | Select Name,Version,ModuleBase
Name Version ModuleBase
---- ------- ----------
PackageManagement 1.0.0.1 C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1
Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 2.8.5.208 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
Get-Package PackageManagement
Get-Package : No package found for 'PackageManagement'.
At line:1 char:1
+ Get-Package PackageManagement
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package], Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
install-module buildhelpers -repository psgallery
get-module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Binary 1.0.0.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script 1.0.0.1 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...
Get-Module buildhelpers -listavailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.0.9 BuildHelpers {Add-TestResultToAppveyor, Export-Metadata, Find-NugetPack...
Get-package buildhelpers
Name Version Source ProviderName
---- ------- ------ ------------
BuildHelpers 2.0.9 https://www.powershellgallery... PowerShellGet
On PS6:
$PSVersionTable
Name Value
---- -----
PSVersion 6.2.1
PSEdition Core
GitCommitId 6.2.1
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 6.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest 6.1.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, …
Manifest 6.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Manifest 6.1.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enab…
Script 2.0.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSRe…
Get-Package #Nothing...? Note-to-self: makes sense since no providers are present for msi etc
Get-Module -Name PackageManagement -ListAvailable | Select Name,Version,ModuleBase
Name Version ModuleBase
---- ------- ----------
PackageManagement 1.3.2 C:\program files\powershell\6\Modules\PackageManagement
Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, …
PowerShellGet 2.1.3.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, In…
install-module buildhelpers -Repository psgallery
Get-Module BuildHelpers -listavailable
Directory: C:\Users\pkadmin\Documents\PowerShell\Modules
ModuleType Version Name PSEdition ExportedCommands
---------- ------- ---- --------- ----------------
Script 2.0.9 BuildHelpers Desk {Add-TestResultToAppveyor, Export-Metadata, Find-N…
Get-Package BuildHelpers
Name Version Source ProviderName
---- ------- ------ ------------
BuildHelpers 2.0.9 https://www.powershellgallery.c… PowerShellGet
Get-Package PackageManagement
Get-Package : No package found for 'PackageManagement'.
At line:1 char:1
+ Get-Package PackageManagement
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.PowerShel\u2026.Cmdlets.GetPackage:GetPackage) [Get-Package], Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
Hmmm..behavior is the same. And with this, confirmation that it only applies to PackageManagement. Which is a pain in the bt when you rely on the 'package*' command-set but actually have to make one exception...and that is for the detection of the module itself which is providing this command-set....not......ok
When I trace back in memory I think I know what happened; I installed a new version of PackageManagement via Install-Package on my machine under PS5 (1.1.7.2) and thus detecting fine under PS5.
So lets do that again:
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
True
install-package PackageManagement -Source PSGallery -Force -AllowClobber
Name Version Source Summary
---- ------- ------ -------
PackageManagement 1.4.1 PSGallery PackageManagement (a.k.a. OneGet) is a new way to d...
PS C:\Users\pkadmin> Get-Module -Name PackageManagement -ListAvailable | Select Name,Version,ModuleBase
Name Version ModuleBase
---- ------- ----------
PackageManagement 1.4.1 C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.1
PackageManagement 1.0.0.1 C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1
restart PS session and uninstall old:
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
#Cannot nicely uninstall, hackitaway
$Modules = Get-Module PackageManagement -listavailable
Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.0.0.1'}.ModuleBase) -Recurse -Force
Get-Module PackageManagement -listavailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
On PS6:
$PSVersionTable
Name Value
---- -----
PSVersion 6.2.1
PSEdition Core
GitCommitId 6.2.1
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
True
install-package PackageManagement -Source PSGallery -Force -AllowClobber
Name Version Source Summary
---- ------- ------ -------
PackageManagement 1.4.1 PSGallery PackageManagement (a.k.a. OneGet) is a new way to dis…
get-package PackageManagement
Name Version Source ProviderName
---- ------- ------ ------------
PackageManagement 1.4.1 https://www.powershellgallery.c… PowerShellGet
Get-Module -Name PackageManagement -ListAvailable | Select Name,Version,ModuleBase
Name Version ModuleBase
---- ------- ----------
PackageManagement 1.4.1 C:\Users\pkadmin\Documents\PowerShell\Modules\PackageManagement\1.4.1
PackageManagement 1.3.2 C:\program files\powershell\6\Modules\PackageManagement
Huh? Whats up with that? I never said that I want the scope to be currentuser? I want a system-wide replace... Let's try to correct..
uninstall-package PackageManagement
uninstall-package : The module 'PackageManagement' of version '1.4.1' in module base folder 'C:\Users\pkadmin\Documents\PowerShell\Modules\PackageManagement\1.4.1' cannot be uninstalled, because one or more other modules 'PowerShellGet' are dependent on this module. Uninstall the modules that depend on this module before uninstalling module 'PackageManagement'.
At line:1 char:1
+ uninstall-package PackageManagement
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.PowerShel\u2026ts.UninstallPackage:UninstallPackage) [Uninstall-Package], Exception
+ FullyQualifiedErrorId : UnableToUninstallAsOtherModulesNeedThisModule,Uninstall-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
uninstall-package PackageManagement -Force
Name Version Source Summary
---- ------- ------ -------
PackageManagement 1.4.1 https://www.pow… PackageManagement (a.k.a. OneGet) is a new way to dis…
install-package PackageManagement -Source PSGallery -Force -AllowClobber -scope AllUsers
Name Version Source Summary
---- ------- ------ -------
PackageManagement 1.4.1 PSGallery PackageManagement (a.k.a. OneGet) is a new way to dis…
Get-Module -Name PackageManagement -ListAvailable | Select Name,Version,ModuleBase
Name Version ModuleBase
---- ------- ----------
PackageManagement 1.4.1 C:\Program Files\PowerShell\Modules\PackageManagement\1.4.1
PackageManagement 1.3.2 C:\program files\powershell\6\Modules\PackageManagement
Uhm....ok...better. But can i force remove the old one?
#Nicely?
Uninstall-Module PackageManagement -RequiredVersion 1.3.2
PackageManagement\Uninstall-Package : No match was found for the specified search criteria and module names 'PackageManagement'.
At C:\program files\powershell\6\Modules\PowerShellGet\PSModule.psm1:12451 char:21
+ ... $null = PackageManagement\Uninstall-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.PowerShel\u2026ts.UninstallPackage:UninstallPackage) [Uninstall-Package], Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
PS C:\temp> Uninstall-Package PackageManagement -RequiredVersion 1.3.2
Uninstall-Package : No package found for 'PackageManagement'.
At line:1 char:1
+ Uninstall-Package PackageManagement -RequiredVersion 1.3.2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.PowerShel\u2026ts.UninstallPackage:UninstallPackage) [Uninstall-Package], Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
#Nope..hackitaway?
$Modules = Get-Module PackageManagement -listavailable
Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3.2'}.ModuleBase) -Recurse -Force
Remove-Item : Access to the path 'C:\program files\powershell\6\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.ArchiverProviders.dll' is denied.
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\program files\po\u2026chiverProviders.dll:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Access to the path 'C:\program files\powershell\6\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.CoreProviders.dll' is denied.
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\program files\po\u2026t.CoreProviders.dll:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Access to the path 'C:\program files\powershell\6\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.dll' is denied.
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\program files\po\u2026ckageManagement.dll:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Access to the path 'C:\program files\powershell\6\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.MetaProvider.PowerShell.dll' is denied.
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\program files\po\u2026ider.PowerShell.dll:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Access to the path 'C:\program files\powershell\6\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PackageManagement.NuGetProvider.dll' is denied.
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\program files\po\u2026t.NuGetProvider.dll:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Access to the path 'C:\program files\powershell\6\Modules\PackageManagement\coreclr\netstandard2.0\Microsoft.PowerShell.PackageManagement.dll' is denied.
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\program files\po\u2026ckageManagement.dll:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : The directory is not empty : 'C:\program files\powershell\6\Modules\PackageManagement\coreclr\netstandard2.0'
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\program files\po\u2026eclr\netstandard2.0:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : The directory is not empty : 'C:\program files\powershell\6\Modules\PackageManagement\coreclr'
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\program files\po\u2026eManagement\coreclr:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : The directory is not empty : 'C:\program files\powershell\6\Modules\PackageManagement'
At line:1 char:1
+ Remove-Item -Path ($Modules.Where{$_.Version -eq [system.version]'1.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\program files\po\u2026s\PackageManagement:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
...and w're stuck with 2 versions...which will result in Desired State Configuration hell when we switch to PS6/7...but that's another story :)
conclusion; dunno. but you'll have to admit that this module does not behave nicely :|