-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Labels
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
Seems #1187 was closed prematurely, this has not been fixed in v0.5.23-beta23.
This is not the same as the feature request for adding -Type to said cmdlet ( #1075 ): Not specifying -Type should return any PSResource, which includes both scripts and modules.
Script to reproduce:
Click to expand
#Requires -Version 5.1
<#
.SYNOPSIS
Reproduce the issue that Microsoft.PowerShell.ResourceGet\Get-PSResource does not return scripts.
.NOTES
Author: Olav Rønnestad Birkeland | github.com/o-l-a-v
Created: 230804
Modified: 230804
.EXAMPLE
# Run from PowerShell ISE or VSCode with the PowerShell extension
& $(Try{$psEditor.GetEditorContext().CurrentFile.Path}Catch{$psISE.CurrentFile.FullPath}) | clip
#>
# Input parameters
[OutputType([System.Void])]
Param()
# PowerShell preferences
$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'
# Assets
$TempDir = [string] '{0}\Temp\Testing\{1}\Scripts' -f $env:LOCALAPPDATA, [datetime]::Now.ToString('yyyyMMddHHmmss')
$ScriptName = [string] 'Get-WindowsAutoPilotInfo'
# Create temp path
Write-Information -MessageData ('{0}# Create temp path' -f [System.Environment]::NewLine)
if (-not [System.IO.Directory]::Exists($TempDir)) {
$null = [System.IO.Directory]::CreateDirectory($TempDir)
}
# Import Microsoft.PowerShell.PSResourceGet
Write-Information -MessageData ('{0}# Import Microsoft.PowerShell.PSResourceGet' -f [System.Environment]::NewLine)
$null = Import-Module -Name 'Microsoft.PowerShell.PSResourceGet'
Write-Information -MessageData (
Get-Module -Name 'Microsoft.PowerShell.PSResourceGet' | `
Format-Table -Property 'ModuleType','Version',@{'Name'='PreRelease';'Expression'={$_.'PrivateData'.'PSData'.'Prerelease'}},'Name' | `
Out-String
)
# Save $ScriptName to temp path
Write-Information -MessageData ('{0}# Save $ScriptName to temp path' -f [System.Environment]::NewLine)
$null = Save-PSResource -Name $ScriptName -SkipDependencyCheck -Path $TempDir -Repository 'PSGallery' -TrustRepository
# List files in $TempDir
Write-Information -MessageData ('{0}# List files in $TempDir' -f [System.Environment]::NewLine)
Write-Information -MessageData (([System.IO.Directory]::GetFiles($TempDir) -as [string[]]) -join [System.Environment]::NewLine -as [string])
# Get PSResources in $TempDir
Write-Information -MessageData ('{0}# Get PSResources in $TempDir' -f [System.Environment]::NewLine)
Get-InstalledPSResource -Path $TempDirOutput of this script when testing:
Click to expand
PS C:\Users\olav.birkeland\OneDrive\IT\Code\PowerShell> & $(Try{$psEditor.GetEditorContext().CurrentFile.Path}Catch{$psISE.CurrentFile.FullPath}) | clip
# Create temp path
# Import Microsoft.PowerShell.PSResourceGet
ModuleType Version PreRelease Name
---------- ------- ---------- ----
Binary 0.5.23 beta23 Microsoft.PowerShell.PSResourceGet
# Save $ScriptName to temp path
# List files in $TempDir
C:\Users\olav.birkeland\AppData\Local\Temp\Testing\20230804111230\Scripts\Get-WindowsAutoPilotInfo.ps1
# Get PSResources in $TempDir
Get-InstalledPSResource: C:\Users\olav.birkeland\OneDrive\IT\Code\PowerShell\Various\Error reports\PSResourceGet\230804 - PSResourceGet 3 beta 23 - Get-PSResource does not return scripts.ps1:61:1
Line |
61 | Get-InstalledPSResource -Path $TempDir
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Error cannot find expected subdirectories in provided path: C:\Users\olav.birkeland\AppData\Local\Temp\Testing\20230804111230\Scripts
PS C:\Users\olav.birkeland\OneDrive\IT\Code\PowerShell>Expected behavior
It should return scripts too.Actual behavior
It does not return scripts.Error details
No response
Environment data
Microsoft.PowerShell.PSResourceGet v3 beta 23
PowerShell x64 v7.3.6 installed with MSIVisuals
Reactions are currently unavailable
