Skip to content

Get-HyperVHostMacRange

Hyper-V: Audits the dynamic MAC address pool range

#Requires -Version 5.1
#Requires -Modules Hyper-V

[CmdletBinding()]
Param (
    [string]$ComputerName = "localhost",

    [PSCredential]$Credential
)

Process {
    try {
        $params = @{
            'ComputerName' = $ComputerName
            'ErrorAction'  = 'Stop'
        }
        if ($Credential) { $params.Add('Credential', $Credential) }

        $hostInfo = Get-VMHost @params
        
        $result = [PSCustomObject]@{
            ComputerName      = $hostInfo.ComputerName
            MacAddressMinimum = $hostInfo.MacAddressMinimum
            MacAddressMaximum = $hostInfo.MacAddressMaximum
            Timestamp         = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the name of the Hyper-V host. Defaults to the local machine.

Specifies the credentials to use for the remote connection.

An interactive directory of PowerShell scripts.