A question on the forum asked about discovering if domain controllers are physical or virtual machines.
This will do the job
foreach ($domain in (Get-ADForest).domains) {
Get-ADDomainController -filter * -server $domain |
sort hostname |
foreach… Read the full text.