0

I'm currently working on a script that automatically updates a package with error handling. I also want it to recognize prerelease packages. For that, I'm using the "Get-InstalledModule" command with its switch parameter -AllowPrerelease. But it's just giving me the major releases?

The versions installed:

PS C:\WINDOWS\system32> Get-InstalledModule -Name BcContainerHelper -AllVersions

Version              Name                                Repository           Description                                                                   
-------              ----                                ----------           -----------                                                                   
2.0.10               BcContainerHelper                   PSGallery            PowerShell module                                                             
2.0.11-preview422    BcContainerHelper                   PSGallery            PowerShell module                                                             
2.0.5                BcContainerHelper                   PSGallery            PowerShell module   

I want the newest prerelease, but instead it gives me the latest major?

PS C:\WINDOWS\system32> Get-InstalledModule -Name BcContainerHelper -AllowPrerelease

Version              Name                                Repository           Description                                                                   
-------              ----                                ----------           -----------                                                                   
2.0.10               BcContainerHelper                   PSGallery            PowerShell module

Is that intended or did I do something wrong?

3
  • I don't know why but my Hi was cut off? So Hi guys! Commented Apr 13, 2021 at 7:55
  • It's unnecessary noise and would have been removed by a community editor.
    – Ramhound
    Commented Apr 13, 2021 at 13:08
  • I agree with you Commented Apr 13, 2021 at 17:36

1 Answer 1

1

Basically, -AllowPrelease does nothing in Get-InstalledModule per MS:

If -AllowPrerelease flag is not specified, prerelease packages will not be shown.

The only exceptions to this in the PowerShellGet module commands are Get-InstalledModule, and some cases with Uninstall-Module.

Get-InstalledModule always will automatically show the prerelease information in the version string for modules.

I have the same behavior as you, but this will return the latest prerelease versions:

(Get-InstalledModule $name -AllVersions | sort version -Descending)[0]`  
1
  • Thanks for answering! I'll try that out tomorrow! Commented Apr 13, 2021 at 17:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .