Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Today = (Get-Date).Date
- Get-ADUser -ResultPageSize 5000 `
- -SearchScope Subtree `
- -Properties * `
- -Filter {(ObjectClass -eq "user") -and (whenCreated -ge $Today) -or (whenChanged -ge $Today)} |
- Where-Object {$_.DistinguishedName -like "*OU=Student*"} |
- ForEach-Object{
- $SchoolID=$_.CanonicalName.split("/")[2].split(" ")[0]
- $SiteID=$_.CanonicalName.split("/")[2].split(" ")[1].substring(1,3)
- Select @{N="School ID";E={$SchoolID}}, @{N="Site ID";E={$SiteID}}, @{N="Login";E={$_.samAccountName}},@{N="PSID";E={$_.EmployeeID}}, @{N="First Name";E={$_.GivenName}}, `
- @{Name="Last Name";Expression={$_.SN}}, @{Name="Account Status";Expression={$_.Enabled}}, @{Name="Email Address";Expression={$_.Mail}}, `
- Title, Department, Company, AccountExpirationDate, @{Name="Account Created";Expression={$_.whenCreated}}, @{Name="Account Changed";Expression={$_.whenChanged}}
- } |
- Export-Csv Test.csv -NoTypeInformation
Advertisement
Add Comment
Please, Sign In to add comment