Read-on for a PowerShell command to get the Active Directory Subnet and Site from the computername or IP Address.
Active Directory Sites represent locations with good network connectivity. An ADSite is often created for each office or a group of offices in a metropolitan area, to generate the replication topology between Domain Controllers, and to help workstations/servers locate closest services.
Active Directory Subnets define the IP ranges included in an AD Site. A member workstation/server will have an IP address that should fall within a defined AD subnet, making it part of an AD Site.
AD Site membership is not fixed. Laptops can move between Sites and Subnets when they roam to another location.
An incorrect or undefined AD subnet can lead to slow logon times and slow access to DFS shares. A domain member would use any server that responds when it isn’t in a defined subnet.
PowerShell script
The Find-ADSite PowerShell function below will return the AD Site and Subnet for a specified computer name or IP Address.
If a company populates subnet descriptions with useful information, it can also identify information such as the specific Office or floor.
AD Administrators may define a catch-all subnet with a wide address range. By default if the IP address is within more than one subnet, the output will only include the smallest range. Use the -AllMatches parameter to see everything.
This article was originally posted on Write-Verbose.com