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

-match on multiple pieces of data?

$
0
0

if ($getip -match 133) {$location = (Get-ADComputer $machine -Properties CanonicalName).CanonicalName; if ($location -match "Acme.org/MGH_Workstations/DL/$machine") {Write-Host "you are in the Correct OU" -ForegroundColor Green} 

    ELSE {$MoveOU = 'OU=DL,OU=MGH_Workstations,DCl=Acme,DC=org'; Get-ADComputer $machine | Move-ADObject -TargetPath $MoveOU}}

The above code is a snippet from a larger script.  I read a file, ping each machine in the file and then find out what vlan it is on. I then check the OU it is in and move it to the correct OU if not already there.

We have a remote site that has 3 different subnets  10.10.133.x  10.10.134.x  10.10.131.x   and instead of doing 3 IF Statements I'd like to do this:

if ($getip -match 133, 134, 131)  but so far this does not work.   I've tried a few differnet ways and each has failed.  Is it possible using -match to do this?


Viewing all articles
Browse latest Browse all 6937

Trending Articles