The following quick PowerShell code helps in retrieving information about the users currently connected to a domain controller.

Execute this command on the client and the result shows the domain controller the users connected to authenticate.

Using WMI and PowerShell

$PCName=”Localhost”
$Query= “select * from Win32_NTDomain where not caption like `”$($env:COMPUTERNAME)`””
Get-CimInstance -Query $Query -ComputerName $PCName | select Caption,ClientSiteName,DnsForestName,DomainControllerName

The output of the command looks like

Caption    ClientSiteName DnsForestName DomainControllerName
-------    -------------- ------------- --------------------
MyDomain       Site1       domain.local  \\DomainController

I hope this quick tip helps,

Take a look at how to uninstall google chrome with PowerShell

Rate this post