Get-DnsClientCache converts/displays an integer for RecordType
Get-DnsClientCache converts/displays an integer for RecordType
String Values are being converted or displayed as integers when piped to Select. How can this be overcome to keep the values outputted as strings Note: RecordType and Status
- Simon Sheppard
- Posts: 191
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: Get-DnsClientCache converts/displays an integer for RecordType
Getting sensible values out of this was harder than I expected, they are both hard coded and in [uint16] so you will need something like this:
Code: Select all
# Hash table of Types
$dnstypes = @{
[uint16]1 = "A"
[uint16]2 = "NS"
[uint16]5 = "CNAME"
[uint16]6 = "SOA"
[uint16]12 = "PTR"
[uint16]15 = "MX"
[uint16]28 = "AAA"
[uint16]33 = "SRV"
}
# via https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/hh872334(v=vs.85)
# Hash table of Status
$dnsStatus = @{
[uint32]0 = "Success"
[uint32]9003 = "NotExist"
[uint32]9701 = "NoRecords"
}
get-dnsclientcache | select name,type, status | ForEach-object {
$out=$_.name + " = " + $dnstypes[$_.type] + " = " + $dnsStatus[$_.status]
$out
}