AD User Information (PS Commands)

Usable PowerShell Commands that can be used to acquire AD User Information


Acquire a list of users with name and location information:

get-aduser -filter * -Properties * | select displayname, name, givenname, surname, CanonicalName, EmailAddress, telephonenumber | export-csv -path c:\export-all.csv


Acquire a list of users who have not logged in for over 180 days:

import-module activedirectory

$180Days = (get-date).adddays(-180)

Get-ADUser -properties * -filter {(lastlogondate -notlike "*" -OR lastlogondate -le $180days) -AND (passwordlastset -le $180days) -AND (enabled -eq $True) -and (PasswordNeverExpires -eq $false) -and (whencreated -le $180days)} | select-object name, SAMaccountname, passwordExpired, PasswordNeverExpires, logoncount, whenCreated, lastlogondate, PasswordLastSet, lastlogontimestamp | export-csv c:\180days.csv

No comments:

Post a Comment