It 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 !