Get-ADUser 导出用户

Get-ADUser导出用户

  • 导出csv
Get-ADUser -Filter * -SearchBase "OU=22users,DC=test,DC=com" |Select SamAccountName,DistinguishedName |Export-csv  -Path c:\1\result.csv -Encoding UTF8
  • 使用foreach
$adlist=Get-ADUser -Filter * -SearchBase "OU=22users,DC=test,DC=com" #-SearchBase 默认等于 -SearchScope Subtree
foreach ($item in $adlist)
{
    $item.DistinguishedName
}
posted @ 2022-03-13 13:05  shenshu  阅读(169)  评论(0编辑  收藏  举报