#region Active Directory Forest Discovery
 
#create a Schedule Token 
$Schedule = New-CMSchedule -RecurInterval Days -RecurCount 7

#Enable the Active Directory Forest Discovery 
Set-CMDiscoveryMethod -ActiveDirectoryForestDiscovery -SiteCode DEX -Enabled:$true -PollingSchedule $Schedule -EnableActiveDirectorySiteBoundaryCreation:$true -EnableSubnetBoundaryCreation:$true

#To run AD Forest Disovery now
Invoke-CMForestDiscovery -SiteCode DEX -Verbose

#endregion Active Directory Forest Discovery