This PowerShell script retrieves information about enabled Active Directory (AD) users, including their SAM account name, last logon time, and organizational unit (OU). The script makes use of several cmdlets and concepts that are common in PowerShell, including filtering, selecting, sorting, and transforming data.
Get-ADUser -Filter * -Properties lastLogon |
Where-Object { $_.Enabled -eq $True } |
Select-Object samaccountname, @{
Name="lastLogon";
Expression={[datetime]::FromFileTime($_.lastLogon)}
Continue Reading...