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

MAC Address matching

$
0
0

Hi

I've been working on a PSH script to rename client workstations after sysprep imaging.

I need assistance with matching the captured MAC address of the client with the known MAC Address and mapping it to a host name...

#borrowed this code from the WWW to get the MAC Address...

function Get-MACAddress {
    param ($strComputer)
    
    $colItems = get-wmiobject -class "Win32_NetworkAdapterConfiguration" -computername $strComputer |Where{$_.IpEnabled -Match "True"} 
    
    foreach ($objItem in $colItems) { 
    
        #$objItem |select Description,MACAddress 
        $objItem | select MACAddress 
    }
}

$MAC = Get-MACAddress localhost | ft -hide

 

#Then, match the MAC Address with known value and set the host name...

Switch ($MAC)

    {
        B8:CA:3C:CD:AE:35 { $newComputerName = "pc01" ; break }
        B8:CA:3D:CE:AE:10 { $newComputerName = "pc02" ; break }
        F3:B7:E2:6B:07:DF { $newComputerName = "pc03" ; break }
        default {"MAC Address not defined."}
    }

 

#Then there is code to rename the computer, etc...

{......}

The $MAC does not appear to be matched, hence my constant result is MAC Address not defined.

 

Any assistance is welcome.

Thanks

--samuel

 


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images