Skip to content

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

@FierlaPi

Description

@FierlaPi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions