Get-DnsClientInfo
Windows: Retrieves DNS client configuration for network interfaces
#Requires -Version 5.1
#Requires -Modules NetTCPIP
[CmdletBinding()]
Param (
[string]$InterfaceAlias = "*",
[string]$ComputerName = $env:COMPUTERNAME,
[pscredential]$Credential
)
Process {
try {
$session = $null
$dnsParams = @{
'ErrorAction' = 'Stop'
}
if ($ComputerName -ne $env:COMPUTERNAME) {
$sessionParams = @{
'ComputerName' = $ComputerName
'ErrorAction' = 'Stop'
}
if ($null -ne $Credential) {
$sessionParams.Add('Credential', $Credential)
}
$session = New-CimSession @sessionParams
$dnsParams.Add('CimSession', $session)
}
$clients = Get-DnsClient @dnsParams | Where-Object { $_.InterfaceAlias -like $InterfaceAlias }
$results = foreach ($c in $clients) {
[PSCustomObject]@{
InterfaceAlias = $c.InterfaceAlias
InterfaceIndex = $c.InterfaceIndex
ConnectionSpecificSuffix = $c.ConnectionSpecificSuffix
RegisterThisAddr = $c.RegisterThisConnectionsAddress
UseSuffixInReg = $c.UseSuffixWhenRegistering
ComputerName = $ComputerName
}
}
Write-Output ($results | Sort-Object InterfaceAlias)
}
catch {
throw
}
finally {
if ($null -ne $session) {
Remove-CimSession $session
}
}
}Specifies the friendly name of the interface (e.g., "Ethernet"). Supports wildcards.
Specifies the name of the target computer. Defaults to the local computer.
Specifies a PSCredential object for remote connection.