I've got an old 2003 DC and need to find old accounts. I'm using the Quest AD module. My question is this: how can I output to a properly formatted CSV file? By properly formatted, I mean something that looks like this:
Mr. Bob Smith, 11/27/2012 08:46:83
Here's what I've got so far:
#Import-Module ActiveDirectory
$days = 10
$today = Get-Date
$daysago = $today.AddDays(-$days)
$accts = Get-QADUser | where{$_.lastLogonTimeStamp -lt $daysago }
ForEach ($var in $accts) {
Write-Host $var.name","$var.lastLogonTimeStamp
}