Skip to content
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

Install fails when manifest references Data with ConvertFrom-StringData #1762

Open
3 tasks done
FierlaPi opened this issue Dec 18, 2024 · 1 comment
Open
3 tasks done

Comments

@FierlaPi
Copy link

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

When trying to install modules from a fileshare repository with ConvertFrom-StringData in the manifest with current prelease of PSResourceGet (1.1.0 rc3), generate an error:

Install-PSResource: The command 'ConvertFrom-StringData' is not allowed in restricted language mode or a Data section.

Getting it from the PS Gallery works fine.

I will give an example using the PackageManagement module for demonstration purposes, but othe modules show the same problem, such as PlatyPS.

Expected behavior

Import-Module Microsoft.PowerShell.PSResourceGet
Register-PSResourceRepository -Name 'My-PSGallery' -Uri \\path\to\file\share -Trusted -Priority 1
Save-PSResource -Name PackageManagement -Repository PSGallery -TrustRepository -AsNupkg -Path \\path\to\file\share
Install-PSResource -Name PackageManagement -Repository My-PSGallery

This should process just fine and make it possible to import the module to use it.

Actual behavior

Install-PSResource -Name PackageManagement -Repository My-PSGallery

Will return:
```PowerShell
Install-PSResource: The command 'ConvertFrom-StringData' is not allowed in restricted language mode or a Data section.
Install-PSResource: Package(s) 'PackageManagement' could not be installed from repository 'My-PSGallery'.


### Error details

```console
Exception             : 
    Type    : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    Message : Package(s) 'PackageManagement' could not be installed from repository 'My-PSGallery'.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
CategoryInfo          : InvalidData: (Microsoft.PowerShel…s.InstallPSResource:InstallPSResource) [Install-PSResource], ResourceNotFoundException
FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
InvocationInfo        : 
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 63
    Line             : install-PSResource -Name PackageManagement -Repository My-PSGallery
    Statement        : install-PSResource -Name PackageManagement -Repository My-PSGallery
    PositionMessage  : At line:1 char:1
                       + install-PSResource -Name PackageManagement -Repository My-PSGallery
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : install-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : 
      0
      1

Environment data

Name                               Version PreRelease ExportedCommands
----                               ------- ---------- ----------------
Microsoft.PowerShell.PSResourceGet 1.1.0              {Compress-PSResource, Find-PSResource, Get-InstalledPSResource, Get-PSResourceRepository…}


Name                      Value
----                      -----
PSVersion                 7.4.6
PSEdition                 Core
GitCommitId               7.4.6
OS                        Microsoft Windows 10.0.22631
Platform                  Win32NT
PSCompatibleVersions      {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion      1.1.0.1
WSManStackVersion         3.0

Visuals

No response

@FierlaPi
Copy link
Author

Added info: Current PackageManagement module version used for the issue is 1.4.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant