For loop for Array in Powershell

I have sample code as below:

$IP=@("IP1","IP2","IP3", "IP4" , "IP5")
$Hostname=@("Host1","Host2","Host3","HOST4", "HOST5")

$data = Read-Host -Prompt 'Please enter the data.'

if ($data -match 'zone1') {
} elseif ($data -match 'site2'){
} elseif ($data -match 'unit5'){
} elseif ($data -match 'ALL DC'){

foreach ($u in $Unity){

echo "This is my IP" $u
echo "This is my hostname" $show


Codework fine for all the options except ALL DC. I want to run some command which use hostname and Ip.

Read more here:

Content Attribution

This content was originally published by GURU SINGH at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: