Get-MACtoIP.psm1

function Get-MACtoIP {
    param (
        [Parameter(Position = 0, Mandatory = $true)][String]$MACAddress
    )
    # Here I have to kinda hackjob the dynamic query of the DHCP servers in the domain due to an issue with server 2012
    # For some reason our 2012 server WILL NOT allow me to WINRM to it useing its FQDN
    # I query the DNS name, then parse off the .sheriffleefl.org and add a comma between the two server names and that makes invoke-command much happier.
    $dhcpservers = Get-DhcpServerInDC | select -ExpandProperty DnsName
    $removeFQDN = $dhcpservers -replace '.sheriffleefl.org','' -replace ' ',','
    
    #I convert the mac address to "-" in case the entry is ":" as win dhcp servers store the clientID as "-".
    $convertedMAC = $MACAddress -replace ':','-'

    Invoke-Command $removeFQDN {Get-DhcpServerv4Scope | Get-DhcpServerv4Lease | where ClientId -eq $using:convertedMAC} | FL
}