Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Multiple where

$
0
0

Hi all trying to put together a script, I took the follwoing from Virtu Al and this works but for one set of variables, For the life of me I cant get this to work if I add an if or elseif statement 

 

$OldNetwork = "PG1 192.168.0" 
$NewNetwork = "PG2 10.1.1"

Get-VM |Get-NetworkAdapter |Where {$_.NetworkName -eq $OldNetwork} |Set-NetworkAdapter -NetworkName $NewNetwork -Confirm:$false

what I would like is something like 

 

$OldNetwork1 = "PG1 192.168.0" 
$NewNetwork1= "PG2 10.1.1"

$OldNetwork2 = "PG10" 
$NewNetwork2= "PG2 "

so if the first "where" statement wouldn't match it would go on and try to match another portgroup.  Any help much appreciated tired of seeing red

 

 

thanks

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles