ps/Modules/Alkami.PowerShell.Common/Public/Get-IPAddressesForName.ps1
2023-05-30 22:51:22 -07:00

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