Having $null object in string[] passed to -Command parameter produces error
artisticcheese opened this issue · 4 comments
Steps to reproduce the issue:
1.
New-Container -Isolation HyperV -Name "first" -Command @("dsadasd", "") -ImageIdOrName "microsoft/iis"
2.
3.
What actually happened?:
Getting error
New-Container : Cannot validate argument on parameter 'Command'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:1 char:56
+ ... ner -Isolation HyperV -Name "first" -Command @("dsadasd", "") -ImageI ...
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [New-Container], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Docker.PowerShell.Cmdlets.NewContainer
What did you expect to happen?:
Supposed to take empty values (like if you used Get-Content to pull contents of text file with empty lines)
Additional information:
Also what is supposed to be fed to -Command? Is it commands from docker file or it can be plainly written powershell script?
Ah interesting. @swernli - I think that -Command
should have [ValidateNotNull]
instead of [ValidateNotNullOrEmpty]
what do you think?
Hmmm... that would prevent this error from occurring, and I don't expect it would cause any other problems. That said, why would someone want to pass an empty string as a command element?
We should go ahead and make this fix anyway, but I'm curious if there is a scenario that @artisticcheese is trying to capture...
I want to have series of commands to be executed on container which are stored in external file.
Dead module