Active Directory – Get a Free Domain Controller

Active Directory – Get a Free Domain Controller

roualin powershell_2 Active Directory - Get a Free Domain ControllerIt could be really usefull to use the -DomainController parameter with many Powershell commands… But How to be sure to find an available DC ?

A little function will help you to do that :

Function Get_Domain_Controller {
$site = [System.DirectoryServices.ActiveDirectory.ActiveDirectorysite]::GetComputerSite()

$back = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().FindDomainController($site).Name
return $back
}

Thanks to .Net to exist !

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site