looking to run a foreach loop with 2 variables here
$vmwareluns = get-content c:\netappluns.txt
$igroup = get-content c:\igroup.txt
foreach ($lun in $vmwareluns) {
add-nalunmap $lun $igroup
}
but fails
do I need a second loop here?
every line in igroup needs to go with all the lines in $lun
You can use nested ForEach loops
$vmwareluns = get-content c:\netappluns.txt
$igroups = get-content c:\igroup.txt
foreach($group in $igroups){
foreach ($lun in $vmwareluns) {
add-nalunmap $lun $igroup
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Maybe a Do loop might work better
$vmwareluns = get-content c:\netappluns.txt
$igroup = get-content c:\igroup.txt
$i=0
$count= $igroup.count
DO
{
add-nalunmap $lun[$i] $igroup[$i]
$i++
}
Until ($i -eq ($count-1))
Or atleast something like that...
You can use nested ForEach loops
$vmwareluns = get-content c:\netappluns.txt
$igroups = get-content c:\igroup.txt
foreach($group in $igroups){
foreach ($lun in $vmwareluns) {
add-nalunmap $lun $igroup
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Lucd. That works