我想获得Active Directory属性中包含的所有详细信息,但是我没有获得部门号。
PowerShell脚本为:
$Properties =
@(
'EmployeeID',
'givenName',
'EmployeeType',
'Departmentnumber'
)
Get-ADUser "Learner" -Properties $Properties |
select $Properties |
Export-Csv C:\Users\Learner\Desktop\test.csv
输出为:
答案 0 :(得分:0)
departmentNumber
是一个多值属性,因此您需要将DepartmentNumber
属性替换为自身的错误版本,例如像这样:
... |
Select-Object $Properties |
Select-Object -Include *, @{n='DepartmentNumber';e={$_.DepartmentNumber[0]}} -Exclude DepartmentNumber |
...
或类似这样:
... |
Select-Object $Properties |
Select-Object -Include *, @{n='DepartmentNumber';e={$_.DepartmentNumber -join ' '}} -Exclude DepartmentNumber |
...