Fix errors when trying to expand IPAddress#57
Open
Xento wants to merge 1 commit intoAndersRodland:masterfrom
Open
Fix errors when trying to expand IPAddress#57Xento wants to merge 1 commit intoAndersRodland:masterfrom
Xento wants to merge 1 commit intoAndersRodland:masterfrom
Conversation
With this fix the following errors disappear:
$dnsAddressList = Resolve-DnsName -Name $fqdn -Server ($dnsServers | Select-Object -First 1) -Type A -DnsOnly | Select-Object -ExpandProperty IPAddress
Select-Object : Die IPAddress-Eigenschaft kann nicht gefunden werden.
In Zeile:1 Zeichen:113
+ ... -First 1) -Type A -DnsOnly | Select-Object -ExpandProperty IPAddress
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.DnsCl...s.DnsRecord_PTR:PSObject) [Select-Object], PSArgumentException
+ FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand
Select-Object : Die IPAddress-Eigenschaft kann nicht gefunden werden.
In Zeile:1 Zeichen:113
+ ... -First 1) -Type A -DnsOnly | Select-Object -ExpandProperty IPAddress
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.DnsCl...s.DnsRecord_PTR:PSObject) [Select-Object], PSArgumentException
+ FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand
This is because of this output:
Resolve-DnsName -Name $fqdn -Server ($dnsServers | Select-Object -First 1) -Type A -DnsOnly
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
hostname.contoso.de A 1200 Answer 172.30.x.x
Name : contoso.de
QueryType : NS
TTL : 86400
Section : Authority
NameHost : dns.contoso.de
Name : contoso.de
QueryType : NS
TTL : 86400
Section : Authority
NameHost : dns2.contoso.de
dns.contoso.de A 86400 Additional 172.18.x.x
dns2.contoso.de A 3600 Additional 172.17.x.x
ladewig
suggested changes
Jan 15, 2021
| $ActiveAdapters = (get-netadapter | Where-Object {$_.Status -like "Up"}).Name | ||
| $dnsServers = Get-DnsClientServerAddress | Where-Object {$ActiveAdapters -contains $_.InterfaceAlias} | Where-Object {$_.AddressFamily -eq 2} | Select-Object -ExpandProperty ServerAddresses | ||
| $dnsAddressList = Resolve-DnsName -Name $fqdn -Server ($dnsServers | Select-Object -First 1) -Type A -DnsOnly | Select-Object -ExpandProperty IPAddress | ||
| $dnsAddressList = Resolve-DnsName -Name $fqdn -Server ($dnsServers | Select-Object -First 1) -Type A -DnsOnly | Where-Object -FilterScript {$_.IPAddress} | Select-Object -ExpandProperty IPAddress |
Contributor
There was a problem hiding this comment.
As we discussed in #58, it might be better to filter on $FQDN as it addresses additional issues beyond yours as follows:
$dnsAddressList = Resolve-DnsName -Name $fqdn -Server ($dnsServers | Select-Object -First 1) -Type A -DnsOnly | Where-Object {$_.Name -eq $fqdn} | Select-Object -ExpandProperty IPAddress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this fix the following errors disappear:
$dnsAddressList = Resolve-DnsName -Name $fqdn -Server ($dnsServers | Select-Object -First 1) -Type A -DnsOnly | Select-Object -ExpandProperty IPAddress
Select-Object : Die IPAddress-Eigenschaft kann nicht gefunden werden.
In Zeile:1 Zeichen:113
Select-Object : Die IPAddress-Eigenschaft kann nicht gefunden werden.
In Zeile:1 Zeichen:113
This is because of this output:
Resolve-DnsName -Name $fqdn -Server ($dnsServers | Select-Object -First 1) -Type A -DnsOnly
Name Type TTL Section IPAddress
hostname.contoso.de A 1200 Answer 172.30.x.x
Name : contoso.de
QueryType : NS
TTL : 86400
Section : Authority
NameHost : dns.contoso.de
Name : contoso.de
QueryType : NS
TTL : 86400
Section : Authority
NameHost : dns2.contoso.de
dns.contoso.de A 86400 Additional 172.18.x.x
dns2.contoso.de A 3600 Additional 172.17.x.x