导出DC列表

$DomainName = (gwmi win32_computersystem).Domain
$dn0 = $DomainName.Split(".")[0]
$dn1 = $DomainName.Split(".")[1]
$dn2 = $DomainName.Split(".")[2]

If ( $dn2 -eq $null )
{$OU = "OU=Domain Controllers,DC=$dn0,DC=$dn1"}
Else {$OU = "OU=Domain Controllers,DC=$dn0,DC=$dn1,DC=$dn2"}

csvde -l "cn" -r "objectClass=computer" -d "$OU" -f dclist.txt -U

 

 

==========================

Get-ADDomainController |select Name,Domain

posted on 2014-01-27 11:04  momingliu11  阅读(334)  评论(0编辑  收藏  举报