PowerShell/PowerShellGet

Install-script error: could not parse script

enthusedcoder opened this issue · 1 comments

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

After installing the latest version of powershellget (3.0.22), I attempted to use the "install-script" cmdlet to install a powershell script from the psgallery. The command that I ran was pretty basic:

install-script -Name wimwitch

I also tried running the command with a couple of additional parameters when I encountered the error:

install-script -Name wimwitch -Force -AllowPrerelease

Regardless of which command I ran, however, I ran into the following error(s) each time:

Install-Script : Could not parse 'C:\Users\john\AppData\Local\Temp\1906e893-f420-43e8-871c-e286378505c5\wimwitch\3.4.6\WIMWitch.ps1' as a PowerShell script file due 
to missing the closing '#>' for HelpInfo comment block
At line:1 char:1
+ Install-Script wimwitch
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Install-PSResource], InvalidOperationException
    + FullyQualifiedErrorId : MissingEndBracketToHelpInfoCommentParseError,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
 
Install-Script : PSScriptFile could not be parsed
At line:1 char:1
+ Install-Script wimwitch
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (Microsoft.Power...stallPSResource:InstallPSResource) [Install-PSResource], InvalidOperationException
    + FullyQualifiedErrorId : PSScriptParseError,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
 
Install-Script : Package(s) 'wimwitch' could not be installed from repository 'PSGallery'.
At line:1 char:1
+ Install-Script wimwitch
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Power...stallPSResource:InstallPSResource) [Install-PSResource], ResourceNotFoundException
    + FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource

However, I was able to successfully install the script when I used the save-script cmdlet from powershellget version 1.0.0.1. Furthermore, this does affect all psgallery scripts, as I am able to successfully install other psgallery scripts using "install-script" from powershellget 3.0.22. This tells me that there is something specific about the wimwitch script that the module does not like when attempting to parse it.

Expected behavior

PS > install-script -Name wimwitch #using latest version of powershellget
(Script successfully installs on computer)

Actual behavior

PS > install-script -Name wimwitch #using latest version of powershellget

(See above error)

Error details

PS > get-error

Exception             :
    Type    :
Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    Message : Package(s) 'wimwitch' could not be installed from repository
'PSGallery'.
    HResult : -2146233088
TargetObject          :
Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
CategoryInfo          : InvalidData:
(Microsoft.PowerShel…s.InstallPSResource:InstallPSResource)
[Install-PSResource], ResourceNotFoundException
FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGe t.Cmdlets.InstallPSResource
InvocationInfo        :
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 4
    Line             : install-script wimwitch
    PositionMessage  : At line:1 char:1
                       + install-script wimwitch
                       + ~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : install-script
    CommandOrigin    : Internal
ScriptStackTrace      : at Install-Script<Process>, C:\Users\john\Documents\W indowsPowerShell\Modules\powershellget\3.0.22\PowerShellGet.psm1: line 1175
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

$PSVersiontable

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

Version

3.0.22

Visuals

No response

Since this error seems to be rooted in the microsoft.powershell.psresourceget module, closing this ticket to move it over to that affected module's repo