for-each loop


trying loop here this

$vmwareluns = get-content c:\luns.txt

$igroup = get-content c:\igroup

 

foreach ($i in $vmwareluns}

    {add-nalunmap $vmwareluns $igroup}

keep getting error

idea?

need add loop? 

---------------------

igroup contents

igroup1

igroup2

igroup3

--------------------

luns.txt contents

lun1

lun2

lun3

 

hi jon,

if can make sure lines matched in these 2 files, example, can find matched pattern igroup[$i] , lun[$i] @ line $i on both text files. in case, please refer script below:

$vmwareluns = get-content d:\1.txt $igroup = get-content d:\2.txt $count = $vmwareluns.count for($i=0;$i -lt $count;$i++){ $igroup[$i] $vmwareluns[$i] #add-nalunmap $vmwareluns[$i] $igroup[$i] }

if there else regarding issue, please feel free post back.

if have feedback on our support, please click here.

best regards,

anna wang


please remember mark replies answers if , unmark them if provide no help. if have feedback technet support, contact tnmff@microsoft.com



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2