Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-module ActiveDirectory
- $CurrentDate = Get-Date
- $CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm')
- get-aduser -filter 'enabled -eq $true' -Properties canonicalName, sAMAccountname,displayName,Enabled,LastLogonDate |
- 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 |
- Export-Csv -Path "edited it goes to a csv" -NoTypeInformation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement