EnterMI-scripts/PowerShell/function_example_Get-MacAddress.ps1
2017-12-14 12:18:37 +01:00

27 lines
782 B
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function Get-MACAddress {
<#
.SYNOPSIS
Retrieves MAC-Address
.DESCRIPTION
Retrieves MAC-Address from each IP enabled networkdevice in a computer
Written by Floris van Enter | EnterMI
.PARAMETER ComputerName
The name of the computer to query.
.EXAMPLE
.\Get-MacAddress -ComputerName 'desktop1'
.EXAMPLE
.\Get-MacAddress -ComputerName 'server1','server2','desktop1'
.LINK
https://www.entermi.nl
#>
[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True,
ValueFromPipeline=$True)]
  $ComputerName
)
$ComputerName | Foreach { Get-WmiObject -Class "Win32_NetworkAdapterConfiguration" -ComputerName $_.ToString() | Where { $_.IPEnabled -eq $True } | Select PSComputerName, MACAddress, Description }
}