You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this error today when having problems getting a newly created script to work, and the error message was not helping. It refers to the #requires statement being formatted incorrectly but the script didn't even have the word "requires" anywhere in it. Turned out to be the HelpMessage parameter in one of the parameters that was empty as i had forgot to write something there.
Seems like it is a parsing error of some kind, not expecting the HelpMessage string to be empty.
In the documentation for HelpMessage it does not state that it cannot be empty.
Error was found on Win7 x64 running Windows Powershell 5.1
Tested on Windows 10 (15063) with Windows Powershell 5.1 and Powershell Core 6.0.0-Beta.4
Steps to reproduce
Take a simple script like this, call it Test-HelpMessage.ps1
PS C:\temp> .\Test-HelpMessage.ps1
.\Test-HelpMessage.ps1 : Cannot process the #requires statement because it is not in the correct format.
The #requires statement must be in one of the following formats:
"#requires -shellid "
"#requires -version <major.minor>"
"#requires -psedition "
"#requires -pssnapin [-version <major.minor>]"
"#requires -modules "
"#requires -runasadministrator"
At line:1 char:1
Suggestion [3,General]: The command Test-HelpMessage.ps1 was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\Test-HelpMessage.ps1". See "get-help about_Command_Precedence" for more details.
Content of $error[0].Exception.InnerException:
Cannot process argument because the value of argument "value" is not valid. Change the value of the "value" argument and run the operation again.
Environment data
$PSVersionTable
Name Value
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.4
OS Microsoft Windows 10.0.15063
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
The text was updated successfully, but these errors were encountered:
@ViperTG I don't think we should allow for an empty string, the current code actually checks against that. However, we should have a better error message. Got fix, working on test.
Description
I found this error today when having problems getting a newly created script to work, and the error message was not helping. It refers to the #requires statement being formatted incorrectly but the script didn't even have the word "requires" anywhere in it. Turned out to be the HelpMessage parameter in one of the parameters that was empty as i had forgot to write something there.
Seems like it is a parsing error of some kind, not expecting the HelpMessage string to be empty.
In the documentation for HelpMessage it does not state that it cannot be empty.
Error was found on Win7 x64 running Windows Powershell 5.1
Tested on Windows 10 (15063) with Windows Powershell 5.1 and Powershell Core 6.0.0-Beta.4
Steps to reproduce
Take a simple script like this, call it Test-HelpMessage.ps1
[CmdletBinding()]
Param (
[Parameter(HelpMessage="")]
[String]$Parameter1
)
Write-Output "Hello"
Run the script .\Test-HelpMessage
Expected behavior
Expect to see "Hello" text as output.
Actual behavior
PS C:\temp> .\Test-HelpMessage.ps1
.\Test-HelpMessage.ps1 : Cannot process the #requires statement because it is not in the correct format.
The #requires statement must be in one of the following formats:
"#requires -shellid "
"#requires -version <major.minor>"
"#requires -psedition "
"#requires -pssnapin [-version <major.minor>]"
"#requires -modules "
"#requires -runasadministrator"
At line:1 char:1
Suggestion [3,General]: The command Test-HelpMessage.ps1 was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\Test-HelpMessage.ps1". See "get-help about_Command_Precedence" for more details.
Content of $error[0].Exception.InnerException:
Cannot process argument because the value of argument "value" is not valid. Change the value of the "value" argument and run the operation again.
Environment data
$PSVersionTable
Name Value
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.4
OS Microsoft Windows 10.0.15063
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
The text was updated successfully, but these errors were encountered: