A simple question about foreach usage

[]: PS C:\Users\admin\Documents> $ips = cat .\ip.txt

[]: PS C:\Users\admin\Documents> $names = cat .\name.txt

[]: PS C:\Users\admin\Documents> $ips,$names | foreach {$_,$_}

I hope the output will be like bellow, how ever, it’s not. Any one can help me ?  P-P01  P-P02  P-P03  P-P04  P-P05  P-P06  P-P07  P-P08  P-P09  P-P10

Unfortunately in this special case it will be a little more complex than that. :wink:

BTW: Please format your code as code here in the forum using the code tag button (pre) provided on the icon bar of the post editor. Thanks.

$IP = Get-Content -Path .\ip.txt
$Name = Get-Content -Path .\name.txt

for ($i = 0; $i -lt $IP.Count; $i++) {
        IP = $IP[$i]
        Name = $Name[$i]

Regardless of that: you might start with learning the very basics of Powershell first. That will save you from a lot of missunderstandings, wasted time and frustrations. :wink:

Hey Olaf ,

Thanks for your answer and your suggestion. I think I will , however , I think I still will post my question here if I meet a problem that I don’t known how to do that in my job , maybe it’s because I haven’t learn that top in the whole learning process or I can’t get an answer from internet.