Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell to CSV

$
0
0

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
}


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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