Skip to content

Scripts installed using Save-PSResource -IncludeXml are not discoverable by Get-InstalledPSResource -Path #1447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
o-l-a-v opened this issue Oct 16, 2023 · 2 comments
Labels
Area-GetPSResource Issue-Bug Something isn't working

Comments

@o-l-a-v
Copy link
Contributor

o-l-a-v commented Oct 16, 2023

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

Scripts installed with Save-PSResource -IncludeXml are not discoverable by Get-InstalledPSResource -Path.

Observed difference in behavior:

  • Save-PSResource -IncludeXml adds <script_name>_InstalledScriptInfo.xml to the same directory as the script itself.
  • Install-PSResource creates a directory InstalledScriptInfos where <script_name>_InstalledScriptInfo.xml is added.

I use Save-PSResource because Install-PSResource installs to OneDrive when known folder move (KFM) is enabled, and Install-PSResource has no override capabilities.

Reproduce:

# Create unique $InstallPath
$InstallPath = [string] '{0}\{1}' -f [System.Environment]::GetFolderPath('Desktop'), [datetime]::Now.ToString('yyyyMMddhhMMss')

# Create path
if (-not [System.IO.Directory]::Exists($InstallPath)) {
    $null = [System.IO.Directory]::CreateDirectory($InstallPath)
}

# Save a module and a script
Save-PSResource -Repository 'PSGallery' -TrustRepository -IncludeXml -Path $InstallPath -Name 'Az.Accounts'
Save-PSResource -Repository 'PSGallery' -TrustRepository -IncludeXml -Path $InstallPath -Name 'Get-WindowsAutoPilotInfo'

# List contents of $InstallPath
Get-ChildItem -Path $InstallPath

# Find installed PSResources
Get-InstalledPSResource -Path $InstallPath

Expected behavior

Modules "installed" using Save-PSResource is discoverable by Get-InstalledPSResource -Path, so should scripts be.

Actual behavior

See expected behavior.

Error details

No error message.

Environment data

  • Windows 11
  • PowerShell v7.3.8
  • Microsoft.PowerShell.PSResourceGet v1.0.0

Visuals

image
@o-l-a-v o-l-a-v changed the title Scripts installed using Save-PSResource -IncludeXml is not discoverable by Get-InstalledPSResource -Path Scripts installed using Save-PSResource -IncludeXml are not discoverable by Get-InstalledPSResource -Path Oct 16, 2023
@o-l-a-v
Copy link
Contributor Author

o-l-a-v commented Oct 17, 2023

Tested moving the XML files to the InstalledScriptInfos directory myself, but scripts were still not discoverable by Get-InstalledPSResource -Path.

I'll be using [Microsoft.PowerShell.PSResourceGet.UtilClasses.TestHooks]::ReadPSGetResourceInfo('<path_to_xml>') for now.

@alerickson alerickson added Area-GetPSResource Issue-Bug Something isn't working and removed Needs-Triage labels Oct 24, 2023
@alerickson
Copy link
Member

Thanks @o-l-a-v we were able to repro this and will fix it in on of the upcoming releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-GetPSResource Issue-Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants