【问题标题】:Active Directory Export via PowerShell (Displayname & EmployeeID) Using Get-ADUser使用 Get-ADUser 通过 PowerShell(显示名称和员工 ID)导出 Active Directory
【发布时间】:2017-01-10 09:00:43
【问题描述】:

我想从我的域中导出所有仅具有employeeid 属性的AD 用户帐户,我想在其中排除特定的OU——想排除所有这些。 这是我运行的脚本,但没有成功 BTW 必须是非空的员工 ID 属性

$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" }

其他代码:

$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" }

【问题讨论】:

    标签: excel windows powershell active-directory


    【解决方案1】:

    您的过滤器参数在错误的位置(Select-Object),它应该与 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" }
    

    【讨论】:

      猜你喜欢
      • 2020-06-28
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 2021-05-01
      相关资源
      最近更新 更多