Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

List users - name, SAMAccountname, Created,LastLogonTimeStamp and Enabled - Speed and elegant solution?

$
0
0

An auditor ask for a AD listing with the following information:

name, SAMAccountname, Created,LastLogonTimeStamp and Enabled

I´ve created two options

Get-ADUser -Filter {ObjectClass -eq 'user'} -Properties SAMAccountname,Name,Enabled,LastLogonTimeStamp,Created | Select-Object SAMAccountname,Name,Enabled,@{Name="LastLogonTimeStamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString('yyyy-MM-dd')}},created | export-csv outputfile.csv -notypeinformation

Get-ADUser -Filter {ObjectClass -eq 'user'} -Properties SAMAccountname,Name,Enabled,LastLogonTimeStamp,Created | Select-Object SAMAccountname,Name,Enabled,@{Name="LastLogonTimeStamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString('yyyy-MM-dd')}},created

These are the most "elegant" and/or more efficient commands?

There are more simpler ways to grab the information?

This suggested approach have a problem? some performance or inneficient problem?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>