Author  Posts 
Hi, $Paths = @( @{NodeName = "VMNAME"; Instance = "Internal" ; Path = "C:\Temp\"}, @{NodeName = "AnotherName" ; Instance = "External" ; Path = "C:\Temp2"}, @{NodeName = "VMNAME2"; Instance = "Internal" ; Path = "C:\Temp1\"} ) If ($ENV:Computername eq "VMNAME1" or "VMNAME2"){ GetChildItem $Paths.Where{$Paths.NodeName eq $ENV:Computername}.Path } When i run this it gets the items on the path for the matching Nodename, but it also tries to get the items of all the other paths that don't exist on this node. Im sure i'm missing something silly, but just can't see it. Thanks TommyQ 

GetChildItem ($PathsWhere{$PSItem.NodeName eq $ENV:Computername}).Path 

If you replace with ($paths  Where NodeName eq $env:COMPUTERNAME).Path it'll work. It looks the Where() method isn't unravelling the hash table 

Thanks guys, I literally just spotted my mistake. If ($ENV:Computername eq "VMNAME1" or "VMNAME2"){ GetChildItem $Paths.Where{$_.NodeName eq $ENV:Computername}.Path } Cheers 

There's also an error in the way you're using or in the if statement Look at this test $x = 4 $y = 5 $z = 4 if ($z eq $x or $y){"$z matches $x or $y"}else{"No match"} $z = 5 if ($z eq $x or $y){"$z matches $x or $y"}else{"No match"} $z = 2 if ($z eq $x or $y){"$z matches $x or $y"}else{"No match"} It gives results of 4 matches 4 or 5 5 matches 4 or 5 2 matches 4 or 5 The last match is clearly wrong. the correct coding is $x = 4 $y = 5 $z = 4 if ($z eq $x or $z eq $y){"$z matches $x or $y"}else{"No match"} $z = 5 if ($z eq $x or $z eq $y){"$z matches $x or $y"}else{"No match"} $z = 2 if ($z eq $x or $z eq $y){"$z matches $x or $y"}else{"No match"} which gives 4 matches 4 or 5 5 matches 4 or 5 No match If you think about the original version ($z eq $x or $y) is equivalent to ( ($z eq $x) or ($y) ) the correct version is equivalent to ( ($z eq $x) or ($z eq $y) ) Check the examples in about_Logical_Operators 
You must be logged in to reply to this topic.