[英]Active Directory Export via PowerShell (Displayname & EmployeeID) Using Get-ADUser
I want to export list all AD User Accounts with just employeeid attribute form my domain where I want to exclude a particular OU -- want to exclude all of them. 我想从我的域中导出所有仅具有employeeid属性的AD用户帐户列表,我想在其中排除特定的OU-希望排除所有它们。 Here is the script I ran, but did not work no luck BTW must be non-null Employee IDattribute 这是我运行的脚本,但是没有用,没运气BTW必须为非Employee IDattribute
$OUDN = "OU=Service Accounts,OU=Accounts,DC=domain,DC=tld"
Get-ADUser -Properties mail |select name,samaccountname,mail,manager,department,employeeid -Filter {Enabled -eq $true} | Where-Object { $_.DistinguishedName -notlike "*,$OUDN" }
Other Code: 其他代码:
$OUDN = "OU=Service Accounts,OU=Accounts,DC=domain,DC=tld"
Get-ADUser -properties CN,Title,samaccountname,mail,displayname,manager,department,distinguishedname,employeeid | select-object CN,Title,employeeid,mail,@{n=”PRODID”;e=”samaccountname”},DisplayName,@{n=”Manager Name”;e={(Get-ADuser -identity $_.Manager -properties displayname).DisplayName}},@{n=”ManagerID”;e={(Get-ADuser -identity $_.Manager –properties samaccountname).samaccountname}},Department -Filter {Enabled -eq $true} | Where-Object { $_.DistinguishedName -notlike "*,$OUDN" }
Your Filter parameter is in the wrong place (Select-Object), it should be used with Get-ADUser. 您的Filter参数放置在错误的位置(选择对象),应与Get-ADUser一起使用。
Get-ADUser -properties CN,Title,samaccountname,mail,displayname,manager,department,distinguishedname,employeeid -Filter {Enabled -eq $true -and employeeID -like '*' } |
select-object CN,Title,employeeid,mail,
@{n=”PRODID”;e=”samaccountname”},DisplayName,
@{n=”Manager Name”;e={(Get-ADuser -identity $_.Manager -properties displayname).DisplayName}},
@{n=”ManagerID”;e={(Get-ADuser -identity $_.Manager –properties samaccountname).samaccountname}},
Department |
Where-Object { $_.DistinguishedName -notlike "*,$OUDN" }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.