-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Minimal version
Invoke-WebRequest "http://www.microsoft.com" -OutFile $null
Version that is more closely related to how that sneaks in as a surprise script breaker
function DoTheThing($file) {
$Params=@{
Uri="http://www.microsoft.com"
OutFile=$file
}
Invoke-WebRequest @Params
}
DoTheThing
Expected behavior
Should return the results of the web call to the output streamActual behavior
Invoke-WebRequest: Cannot validate argument on parameter 'OutFile'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.(Works correctly in 7.2.17 and 7.3.3)
### Error details
```console
Exception :
Type : System.Management.Automation.ParameterBindingValidationException
Message : Cannot validate argument on parameter 'OutFile'. The argument is null or empty. Provide an argument that is not null or empty, and then try t
he command again.
ParameterName : OutFile
ParameterType : string
ErrorId : ParameterArgumentValidationError
Line : 1
Offset : 46
CommandInvocation :
MyCommand : Invoke-WebRequest
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 35
Line : Invoke-WebRequest "http://www.microsoft.com" @h
Statement : Invoke-WebRequest "http://www.microsoft.com" @h
PositionMessage : At line:1 char:1
+ Invoke-WebRequest "http://www.microsoft.com" @h
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Invoke-WebRequest
PipelineLength : 1
PipelinePosition : 1
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Cannot validate argument on parameter 'OutFile'. The argument is null or empty. Provide an argument that is not null or empty, and then try the
command again.
HResult : -2146233087
CategoryInfo : InvalidData: (:) [Invoke-WebRequest], ParentContainsErrorRecordException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
InvocationInfo :
MyCommand : Invoke-WebRequest
ScriptLineNumber : 1
OffsetInLine : 46
HistoryId : 35
Line : Invoke-WebRequest "http://www.microsoft.com" @h
Statement : @h
PositionMessage : At line:1 char:46
+ Invoke-WebRequest "http://www.microsoft.com" @h
+ ~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
TargetSite :
Name : BindParameter
DeclaringType : System.Management.Automation.ParameterBinderBase, System.Management.Automation, Version=7.4.0.500, Culture=neutral, PublicKeyToken=31bf3856ad
364e35
MemberType : Method
Module : System.Management.Automation.dll
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : System.Management.Automation.ValidationMetadataException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
HResult : -2146233087
CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : ArgumentIsNull
TargetSite :
Name : Validate
DeclaringType : System.Management.Automation.ValidateNotNullOrAttributeBase
MemberType : Method
Module : System.Management.Automation.dll
Message : The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.ValidateNotNullOrAttributeBase.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBinding
Flags flags)
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBinding
Flags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, Paramet
erBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParame
ter parameter, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandP
arameter parameter)
at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets, Collection`1 arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location ---
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElem
entAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : InvalidData: (:) [Invoke-WebRequest], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
InvocationInfo :
MyCommand : Invoke-WebRequest
ScriptLineNumber : 1
OffsetInLine : 46
HistoryId : 35
Line : Invoke-WebRequest "http://www.microsoft.com" @h
Statement : @h
PositionMessage : At line:1 char:46
+ Invoke-WebRequest "http://www.microsoft.com" @h
+ ~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Red Hat Enterprise Linux 8.8 (Ootpa)
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No really necessary, literally just paste Invoke-WebRequest "http://www.microsoft.com" -OutFile $null into a shell and watch the error show up
fbrosseau
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module