Posts

Showing posts with the label WMI

Powershell Get MAC Address

Below is a powershell function used to get a list of MAC addresses on a computer using WMI: function Get-MACAddress { <#     .SYNOPSIS       Displays the list of MAC addresses on a computer.     .DESCRIPTION      This function lists all MAC addresses on local computer or a remote one using WMI.     .EXAMPLE      Get-MACAddress      This command returns a list of all MAC addresses on the local computer.     .EXAMPLE      Get-MACAddress -ComputerName client01 -Credential $cred      This command returns a list of all MAC addresses on computer 'client01' using the $cred credentials. #>     Param     (         [string]$ComputerName = ".",         [system.management.automation.psCredential]$Credential     )     if($Credential)     {   ...

How to get Microsoft Windows system info using Powershell

There are many times that I have to get the system information like Windows Edition, Version, Architecture etc, in order to create support case or post to a forum. Since I use Powershell for almost everything, I have a script with the following commands to get that info: Windows Edition (Get-WmiObject -class Win32_OperatingSystem).Caption Windows Version (Get-WmiObject -class Win32_OperatingSystem).Version Processor Info (Get-WmiObject -Class Win32_OperatingSystem).OSArchitecture I'm using WMI cause I want to be able to get the above info from remote systems as well. If you want more information about a system take a look at the Win32_OperatingSystem class  here . If you want to act based on the above info, it may be better to use some environmental variables and get the exact values.

Windows Username to SID mapping

I needed to map the sids of some users to their usernames the other day so I though that I should be able to use WMI to do it. Indeed, you can use the command wmic useraccount get name,sid  that will output a list of usernames and their sids. If you try to run this on Powershell you'll get an error message about invalid GET expression, that is because of the comma. You can use the Start-Process cmdlet and start the command with the necessary arguments.