22 lines
447 B
PowerShell
22 lines
447 B
PowerShell
Function Get-IPAddressesForName {
|
|
<#
|
|
.SYNOPSIS
|
|
Get the IP addresses for a hostname, or return the IP address passed in
|
|
#>
|
|
[CmdletBinding()]
|
|
[OutputType([System.String])]
|
|
Param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$hostname
|
|
)
|
|
|
|
if (!$hostname) {
|
|
throw 'must supply a value'
|
|
}
|
|
if (!!($hostname -As [IPAddress])) {
|
|
$hostname;
|
|
} else {
|
|
(Resolve-DnsName -Type A $hostname).IPAddress;
|
|
}
|
|
}
|