alexT
1
Hi,
Trying to run a script in automation with parameters.
Here is the simple code :
testparam
param(
[Parameter(Mandatory=$true)]
[String[]] $computerList
)
foreach($computer in $computerList){
write-host “… : $computer”
}
Calling the script with param PC1,PC2,PC3
The output with automation :
[INF] … : PC1,PC2,PC3
The output with PS 5.1 :
… PC1
… PC2
… PC3
Could you help me with this ?
adam
2
We are adding the ability to enter string arrays in 1.5. Until then, you’ll need to split the string yourself.
param(
[Parameter(Mandatory=$true)]
[String] $computerList
)
foreach($computer in $computerList.Split(',')){
write-host “… : $computer”
}
String arrays seem to be working for me, but the display under the parameters section is far from ideal - it shows XML. I’m on v1.5.8. See screenshot:
1 Like