Showing posts with label WMIC. Show all posts
Showing posts with label WMIC. Show all posts

Thursday, March 19, 2015

Check the credential of mapped network drive by WMI

Assuming that you'd like to know the user name of mapped network drive. The easy way to find the user name by performing wmic on Command Prompt or PowerShell.

wmic netuse where localname="<Drive letter name>" get UserName /value


You don't need to provide administrator's credential to perform this command.

To check the user name by PowerShell, we can perform the following cmdlets.

Get-WmiObject -Class Win32_NetworkConnection | Select UserName


For PowerShell 3.0 or later, we can perform Get-CimInstance -ClassName Win32_NetworkConnection | Select UserName


By the way, there is a useful tool named WMI Explorer. It's easy for us to find the WMI class.

This posting is provided “AS IS” with no warranties, and confers no rights!

Wednesday, December 3, 2014

3 ways to get remote computers MAC address on Windows Servers or Workstations

There are many ways to get remote computers MAC address on Windows. In this post, I'd like to show 3 ways to get MAC addresses. To get remote computers MAC address, you need to have administrative credential on remote computers and make sure firewalls of computers or network don't block the connection between both computers.

Getmac
Getmac is a built-in command started from Windows XP to get mac addresses from a local computer or remote computer.

On "Command Prompt", perform "getmac /v /s <Remote Computer Name> /U <Remote or Domain User Account with administrative privilege> /FO <List, Table or CSV>" to get MAC addresses from a remote computer.


Enter the password of the account to get the result.

Remark: Both computers communicate with TCP port 135.

Windows Management Instrumentation Command-line (WMIC)
Windows Management Instrumentation Command-line (WMIC) is a command to work with WMI to get or modify the settings of a computer. In this case, I'm going to use wmic to get a remote computer MAC address.

On "Command Prompt", perform "wmic /user:<Remote or Domain User Account with administrative privilege> /node:<Remote computer name> nic list brief".


Enter the password of the account to get the result.

PowerShell
PowerShell is a good way to get information from computers. It's easy for administrators to learn and use. By the way, we can perform the following cmdlet to get MAC address from remote computers.

On "PowerShell" console, perform "Invoke-Command -ComputerName <Remote Computer Names> -Credential (Get-Credential) -ScriptBlock {Get-CimInstance -ClassName Win32_NetworkAdapter | FT Name,MacAddress -AutoSize}" on Windows 8, Windows 8.1, Windows Server 2012 or Windows Server 2012 R2.


Enter the user name and password with administrative privilege of the remote computer.


Remark: Get-CimInstance is a built-in cmdlet on PowerShell 3.0 or later. For Windows 7 or Windows Server 2008 R2, we can perform "Get-WmiObject -Class Win32_NetworkAdapter -ComputerName <Remote Computer Name> -Credential (Get-Credential)".


Enter the user name and password with administrative privilege of the remote computer.


Eventually, we got MAC addresses from above methods.

More information:




This posting is provided “AS IS” with no warranties, and confers no rights!

Monday, July 8, 2013

Using wmic finds a machine serial number

It is easy for us to find a computer serial number by using wmic.

1. On a computer, log in as Administrator.
2. Launch "Command Prompt" as administrator.
3. Perform "wmic bios get serialnumber".


References:


This posting is provided “AS IS” with no warranties, and confers no rights!