Gets one or more Active Directory subnets.


Example 1: Get total subnets count

(Get-ADReplicationSubnet -Filter *).Count



Example 2: Get subnets in a specified location

Get-ADReplicationSubnet -Filter "Location -like '*India'"



Example 3: Get subnets with a specified name

Get-ADReplicationSubnet -Identity "192.168.10.0/24"



Example 4: Determine Which Subnet the Domain Controller is Using

$siteName = (Get-ADDomainController -Identity "DC1").Site

Get-ADReplicationSubnet | Where-Object {$_.Site -eq $siteName} | Select-Object Name





Example 5: List domain controllers with their sites

Get-ADDomainController -Filter * | Select-Object Name, Site



Example 6: List all subnets and their associated sites

Get-ADReplicationSubnet | Select-Object Name, Site



Example 7: Find which subnet a DC's site is using

Get-ADReplicationSubnet | Where-Object {$_.Site -eq "SiteName"} | Select-Object Name



Example 8: Find the subnet your local machine is using

$localDC = Get-ADDomainController -Discover -Service "LDAP"

$siteName = $localDC.Site

Get-ADReplicationSubnet | Where-Object {$_.Site -eq $siteName} | Select-Object Name