如何使用 powershell 在 AD 中创建包含 OU 列表的表
我在Active Directory中有许多子文件夹,我想计算那里的用户数量。我找到了与PowerShell和Get Aduser命令一起使用的方法,但是我认为必须有一种方法来优化与我想要的所有子文件夹一起构建表格。
通常,以下脚本对我有用,但是我不知道我是否可以递归地浏览所有子文件夹,最后创建一个CSV,每个子文件夹的用户数量。
echo "ACC - total:" (Get-ADUser -Filter * -SearchBase 'OU=Users,OU=ACC,OU=Clients,DC=SSICloud,DC=local' ).count
echo "All Car - total:" (Get-ADUser -Filter * -SearchBase 'OU=Users,OU=All Car,OU=Clients,DC=SSICloud,DC=local' ).count
结果:
ACC - Total:
10
All Car - Total:
11
谢谢
I have in my active directory a number of subfolders and I want to count the number of users there. I found a way to do with powershell and the Get ADUser command, however I think there must be a way to optimize this to build a table with all the subfolders I want.
normally the following script works for me, but I don't know if I can recursively go through all the subfolders and finally create a csv with the number of users per subfolder.
echo "ACC - total:" (Get-ADUser -Filter * -SearchBase 'OU=Users,OU=ACC,OU=Clients,DC=SSICloud,DC=local' ).count
echo "All Car - total:" (Get-ADUser -Filter * -SearchBase 'OU=Users,OU=All Car,OU=Clients,DC=SSICloud,DC=local' ).count
outcome:
ACC - Total:
10
All Car - Total:
11
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以通过域中的所有OUS递归搜索,然后您可以将OU的
dickectundedname
作为参数作为-Searchbase
< /a>获取您的报告:get-aduser
Get-ADOrganizationalUnit
can search recursively through all OUs in your Domain, you can then pass theDistinguishedName
of the OU as argument to the-SearchBase
parameter ofGet-ADUser
to get your report: