Get Primary, Secondary, Tertiary DNS values and more from Multiple Servers
Came across a unique request to get primary, secondary, and tertiary DNS values for multiple computers/servers across the domain. I started writing the script and got what I wanted.
Now this started off as just to query for DNS Server information, but then I thought to add other pieces to get myself a good Network Inventory of all the servers in the environment.
I am utilizing the Win32_NetworkAdapterConfiguration WMI Class to get the required information.
You can modify the script below to suit your needs. The complete list of settings that can be captured:
string Caption; string Description; string SettingID; boolean ArpAlwaysSourceRoute; boolean ArpUseEtherSNAP; string DatabasePath; boolean DeadGWDetectEnabled; string DefaultIPGateway[]; uint8 DefaultTOS; uint8 DefaultTTL; boolean DHCPEnabled; datetime DHCPLeaseExpires; datetime DHCPLeaseObtained; string DHCPServer; string DNSDomain; string DNSDomainSuffixSearchOrder[]; boolean DNSEnabledForWINSResolution; string DNSHostName; string DNSServerSearchOrder[]; boolean DomainDNSRegistrationEnabled; uint32 ForwardBufferMemory; boolean FullDNSRegistrationEnabled; uint16 GatewayCostMetric[]; uint8 IGMPLevel; uint32 Index; uint32 InterfaceIndex; string IPAddress[]; uint32 IPConnectionMetric; boolean IPEnabled; boolean IPFilterSecurityEnabled; boolean IPPortSecurityEnabled; string IPSecPermitIPProtocols[]; string IPSecPermitTCPPorts[]; string IPSecPermitUDPPorts[]; string IPSubnet[]; boolean IPUseZeroBroadcast; string IPXAddress; boolean IPXEnabled; uint32 IPXFrameType[]; uint32 IPXMediaType; string IPXNetworkNumber[]; string IPXVirtualNetNumber; uint32 KeepAliveInterval; uint32 KeepAliveTime; string MACAddress; uint32 MTU; uint32 NumForwardPackets; boolean PMTUBHDetectEnabled; boolean PMTUDiscoveryEnabled; string ServiceName; uint32 TcpipNetbiosOptions; uint32 TcpMaxConnectRetransmissions; uint32 TcpMaxDataRetransmissions; uint32 TcpNumConnections; boolean TcpUseRFC1122UrgentPointer; uint16 TcpWindowSize; boolean WINSEnableLMHostsLookup; string WINSHostLookupFile; string WINSPrimaryServer; string WINSScopeID; string WINSSecondaryServer;
Since the scripts are querying for information it is best if it runs from a DC or a privileged server with an account that has privileged access.
To get the results you need the following two scripts:
I needed to get all the network information for all the domain controllers in the domain. So the following code retrieves it for me. This came really handy in viewing all the DNS settings setup on all the DCs and correcting them if needed.
This will get the information and export to an excel file that you can have handy for reference or auditing. Hope this helps!
Author
Related Posts
Diving into Primary Refresh Tokens and Authentication Strengths in Microsoft Entra ID
Microsoft Entra ID is the backbone of modern identity management, powering secure access to cloud and hybrid resources. At its core, the...
- authentication
- Biometrics
- Certificate-based Authentication
- Conditional Access
- Cybersecurity
- Device Binding
- Federated Authentication
- FIDO2
- Hybrid Access
- Identity Management
- Kerberos
- MFA
- Microsoft Authenticator
- Microsoft Entra ID
- Multi-factor Authentication
- NTLM
- OAuth 2.0
- OpenID Connect
- Passwordless
- Phishing-resistant
- Primary Refresh Token
- PRT
- SAML
- Security Keys
- Single Sign-On
- Smartcard
- SSO
- Temporary Access Pass
- Windows Hello
- WS-Federation
Mastering PRT Delayed Renewal in Microsoft Entra ID: Controls, Configurations, and Real-World Scenarios
In the evolving landscape of identity management, the Primary Refresh Token (PRT) stands as a cornerstone of seamless single sign-on (SSO) in...
Read out all
Understanding Tokens in Microsoft Entra ID: Types, Lifetimes, and Beyond
In the world of modern identity and access management, tokens are the digital keys that unlock secure access to resources. Microsoft Entra...
Read out all
Adding an Application Registration\ Service Principal to another Application Registration\ Service Principal
Typically when working with App Roles in Azure Active Directory for a single application registration or service principal and then self consuming...
Read out all
Get all the domains controllers in the AD forest along with their current FSMO roles
In a large enterprise an admin would need to keep track of all the domains in a AD forest, the domain names,...
Read out all
Force synchronization for DFSR-replicated SYSVOL
One of my clients had a problem with processing GPO on client computers. Different computers applied different settings from the same GPO...