PoshCode Archive  Artifact [9dff83df03]

Artifact 9dff83df03dfdd8d4c73167641343b86e8ea3af2f8080d144a6ea6763430a52e:

  • File Get-MyDomain.ps1 — part of check-in [0fb24c4e82] at 2018-06-10 14:23:13 on branch trunk — 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> (user: unknown size: 832)

# 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
}