- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
$MyList = @()
$MyList += "VM1";
$MyList += "VM2";
$Mylist[1]|Get-VM;
This gives an error instead of showing the result for Get-VM VM2
Get-VM : Cannot process argument transformation on parameter 'Location'. Strings as pipeline input are not supported.
At line:4 char:12
+ $Mylist[1]|Get-VM;
+ ~~~~~~
+ CategoryInfo : InvalidData: (VM2:String) [Get-VM], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM
This workaround works:
$Mylist[1] | ForEach-Object{ Get-VM $_}
Why isn't is possible just to use $Mylist[1] | Get-VM
Joern Ravnsbaek