Getting mac address using xp_cmdshell

  • Hi Friends

    I am trying to write a sql script to extract the mac address of other sql clients in the network. For that I have enabled the xp_cmdshell in SQL server and for getting the mac address I am using getmac command.

    I am able to extract the server's MAC address using xp_cmdshell. But when I try to run getmac through xp_cmdshell to get other client's MAC address, am getting an error

    "ERROR: Logon failure: unknown user name or bad password."

    The command executed was

    getmac /s CLIENT /u administrator /p password

    So I tried it on Windows Server 2003 command prompt and to my surprise it worked and provided me the client's MAC address.

    Is there any limitation or issues for xp_cmdshell with getmac in SQL Server 2005?

    I am running SQL Server 2005 on Windows 2003 and the clients are running Windows Vista.

    Could you please share your thoughts. 🙂

    Thanks

  • There should be no restriction from an xp_cmdshell perspective. Can you get other xp_cmdshell commands to run, like dir c:\, and the like? Also, are you using the exact same username/password combo for getmac when you do it from a command shell as when you do it from SQL Server?

    K. Brian Kelley
    @kbriankelley

  • I am able to run other commands like ping, dir etc

    I am giving the exact username and password I gave at the command line.

    But the confusing fact is I am able to get the mac address of the server machine from xp_cmdshell.

    Some clients are giving error like "RPC not running".

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply