# encoding: ascii
# api: powershell
# title: Get-MyDomain
# description: Get-MyDomain retrieves the current IP of the user (Or, the first if there are multiple active cards) then performs a DNS lookup to retrieve the domain. If it is unable to reverse it, it displays Unknown:<IP>
# version: 0.1
# type: function
# license: CC0
# function: Get-MyDomain
# x-poshcode-id: 731
# x-archived: 2008-12-18T09:45:13
#
# Just a simple little function, useful for location based scripts.
#
Function Get-MyDomain() {
# Written by Jeremy D. Pavleck - Pavleck.NET
$IP = ((Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property IPAddress -First 1).IPAddress[0])
trap {
return "Unknown:$($IP)"
}
return [System.Net.DNS]::GetHostByAddress($IP).HostName
}