PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
489 stars 94 forks source link

`Get-InstalledPSResource` does not return scripts #1187

Closed o-l-a-v closed 1 year ago

o-l-a-v commented 1 year ago

Prerequisites

Steps to reproduce

Testing out beta 22 manually downloaded from PowerShellGallery ( https://www.powershellgallery.com/packages/PSResourceGet ), I noticed that Get-InstalledPSResource does not return scripts.

There's also no parameter -Type, like PackageManagement\Get-Package for instance has. I'd expect that, as AFAIK both scripts and modules are PSResources.

Example command, I've set the module path in user context to be outside OneDrive.

Get-InstalledPSResource -Path ('{0}\Microsoft\PowerShell\Scripts' -f $env:LOCALAPPDATA)

Expected behavior

Return a list of scripts and modules (installed by script dependencies) found in said directory.

Actual behavior

PS C:\Users\redacted> Get-InstalledPSResource -Path ('{0}\Microsoft\PowerShell\Scripts' -f $env:LOCALAPPDATA)

Name         Version   Prerelease Repository Description
----         -------   ---------- ---------- -----------
AzureAD      2.0.2.180            PSGallery  Azure Active Directory V2 General Availability Module.…
AzureAD      2.0.2.140            PSGallery  Azure Active Directory V2 General Availability Module.…
PSIntuneAuth 1.2.3                PSGallery  Provides a function to retrieve an authentication token for Intune Graph API calls.

PS C:\Users\redacted>

Error details

No response

Environment data

PSResourceGet v3 beta 22
PowerShell x64 v7.3.4 installed with MSI

Visuals

No response

ThomasNieto commented 1 year ago

Get-InstalledPSResource returns the resource but incorrectly tags it as a module not script. Install-PSResource works as expected.

Install-PSResource Get-WindowsAutoPilotInfo -PassThru | select Name, Type

Name                       Type
----                       ----
Get-WindowsAutoPilotInfo Script

Get-InstalledPSResource Get-WindowsAutoPilotInfo | select Name, Type

Name                       Type
----                       ----
Get-WindowsAutoPilotInfo Module
alerickson commented 1 year ago

Just opened a PR for one of the issues

There's also no parameter -Type, like PackageManagement\Get-Package for instance has. I'd expect that, as AFAIK both scripts and modules are PSResources.

Is a script a PSResource?

A script is a PSResource and I like the suggestion of adding a -Type parameter to the cmdlet. I opened a new issue here to track that issue separately

o-l-a-v commented 1 year ago

@alerickson

This issue isn't fixed: Shouldn't Microsoft.PowerShell.PSResourceGet\Get-InstalledPSResource with -Path should detect both modules and scripts if said path contains both?

Example with v0.5.23-beta23

image

Also, the new issue you said you created for -Type: It links to this issue?