is it possible to specify an array in param
script.ps1 $vmhosts ?
Same reason the following is not listed in a column.
Write-Host $vmhost
That is the way the PS output engine formats an array of strings.
If you want them on separate lines, you could do
Write-Host ($vmhost -join "`n")
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Of course, see this snippet for example.
Same goes for a script in a .ps1 file, define the param as an array ([PSObject[]]$VMHost for example)
{
param(
[int[]]$Array
)
0..$Array.Count | % {
$Array[$_]
}
}
Do-Something -Array 1, 2, 3
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks luc
any idea why write-host doesnt list them in column?
{
param(
[PSObject[]]$VMHost
)
write-host $vmhost
}
$vmhost contents is
test1
test2
test3
test4
Same reason the following is not listed in a column.
Write-Host $vmhost
That is the way the PS output engine formats an array of strings.
If you want them on separate lines, you could do
Write-Host ($vmhost -join "`n")
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks