locked
Check if mac address is on the server RRS feed

  • Question

  • Hi guys,

    i would like to check if a specified mac address is present on the server, if it doesn' t the script exit.

    i wrote this:

    $Mac1 = "00-0A-A7-7B-AC-E2"
    $ServerMacs = Get-CimInstance win32_networkadapterconfiguration | select description, macaddress
    
    IF ($ServerMacs.macaddress -contains $Mac1)
    {
    Write-Host -ForegroundColor Green "RUNNING SCRIPT"
    }
    ELSE {Write-Host -ForegroundColor Magenta "SCRIPT EXITING"}
    I think that problem is when compare the string..

    Wednesday, August 16, 2017 12:57 PM

Answers

  • Hi Ramses,

    dunno how it is noted for you, but when testing it on my machine, it returns the MAC with ":" not "-". May need to update your $mac1 variable.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Ramses147 Wednesday, August 16, 2017 1:05 PM
    Wednesday, August 16, 2017 1:01 PM

All replies

  • Hi Ramses,

    dunno how it is noted for you, but when testing it on my machine, it returns the MAC with ":" not "-". May need to update your $mac1 variable.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Ramses147 Wednesday, August 16, 2017 1:05 PM
    Wednesday, August 16, 2017 1:01 PM
  • Hi fwn !

    yes right, i correct it, THAT'S THE PROBLEM ! 

    sorry for the foolish question

    Wednesday, August 16, 2017 1:05 PM