Difference between revisions of "List all AD enabled staff users"

From MyWiki
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<source lang="powershell">
 
<source lang="powershell">
 
import-module ActiveDirectory
 
import-module ActiveDirectory
Get-ADUser   -LDAPFilter "(&(employeetype=staff)(!userAccountControl:1.2.840.113556.1.4.803:=2))"
+
Get-ADUser -LDAPFilter "(&(employeetype=staff)(!userAccountControl:1.2.840.113556.1.4.803:=2))"   -Properties office, sAMAccountName, givenName, sn, employeetype,uid |  Select office, sAMAccountName, givenName, sn, employeetype,@{n="uid";e={[string]$_.uid}} |   Export-Csv -Path c:\Scripts\Users.csv -NoTypeInformation
   -Properties office, sAMAccountName, givenName, sn, employeetype,uid |   `
+
  Select office, sAMAccountName, givenName, sn, employeetype, @{n="uid";e={[string]$_.uid}} |  `
+
  Export-Csv -Path c:\Scripts\Users.csv -NoTypeInformation
+
 
</source>
 
</source>

Latest revision as of 13:30, 1 September 2016

import-module ActiveDirectory
Get-ADUser  -LDAPFilter "(&(employeetype=staff)(!userAccountControl:1.2.840.113556.1.4.803:=2))"   -Properties office, sAMAccountName, givenName, sn, employeetype,uid |  Select office, sAMAccountName, givenName, sn, employeetype,@{n="uid";e={[string]$_.uid}} |   Export-Csv -Path c:\Scripts\Users.csv -NoTypeInformation