Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Import-module ActiveDirectory
  2. $CurrentDate = Get-Date
  3. $CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm')
  4. get-aduser -filter 'enabled -eq $true' -Properties canonicalName, sAMAccountname,displayName,Enabled,LastLogonDate |
  5. select @{Name = "OU"; Expression = {($_.canonicalname -Split "/")[-2]}},@{Name = "Account"; Expression = {$_.sAMAccountname}},@{Name = "User Name"; Expression = {$_.displayName}},Enabled,@{Name = "Last Logged In"; Expression = {$_.LastLogonDate}} |Sort-Object OU |
  6. Export-Csv -Path "edited it goes to a csv" -NoTypeInformation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement