windows – 使用Get-ADUser时,如何在PowerShell中将用户的域信息
发布时间:2020-12-13 22:51:17 所属栏目:Windows 来源:网络整理
导读:我正在尝试枚举林中每个用户所属的名称,samaccountname和域,并将其写入文本文件. 我现在的脚本是: Import-Module ActiveDirectory$domains = "root.org","child1.root.org","child2.root.org"ForEach ($d in $domains){Get-ADUser -Filter * -ResultSetSize
我正在尝试枚举林中每个用户所属的名称,samaccountname和域,并将其写入文本文件.
我现在的脚本是: Import-Module ActiveDirectory $domains = "root.org","child1.root.org","child2.root.org" ForEach ($d in $domains){ Get-ADUser -Filter * -ResultSetSize $null -Server $d -Properties name,samaccountname | Select-Object name,samaccountname | out-file c:usersmdmarradesktopusers.txt -append } 我需要的是每行末尾的$d的值,以便输出看起来像 name samaccountname domain ---- -------------- ------ Marra,Mark mdmarra root.org
这是您可以使用Select-Object中的哈希表轻松实现的:
ForEach ($d in $domains){ Get-ADUser -Filter * -ResultSetSize $null -Server $d -Properties name,samaccountname,@{ Name = 'domain'; Expression = { $d }} | out-file c:usersmdmarradesktopusers.txt -append } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 是否可以在Windows 7中断开WebDAV共享?
- windows查看网络常用cmd命令
- windows-server-2012-r2 – Server 2012无法找到C:Boot to
- windows2003服务器C盘的清理方法
- windows-7 – Outlook加密电子邮件boo boo
- 在windows cmd的子目录中运行命名.exe
- Windows – 以静默方式在我的计算机上卸载并安装应用程序
- windows-7 – 如何实现自定义UAC权限UI?
- windows – 如何将子域重定向到另一个本地ip:端口与IIS?
- ASP.NET下跨应用共享Session和使用Redis进行Session托管