One of the nicest things about Powershell is once you understand the Syntax it’s incredibly easy to just BUILD stuff!
How about having a filename where the Current Date is part of it? Say a log file?
There are many nice ways to do this, but here’s a “quick and Dirty one”
$Logname=($GET-DATE).toshortdatestring().Replace(“/”,”-“)
“BLAH!” say the Itpros in the audience. “WHAT IS THAT?!”
That is where Powershell is interesting if your NOT a Developer but are at least a LITTLE TEENY bit interested in what’s held in an Object.
It has Methods. But we’ll get into that in another post. What THIS little line gives YOU is a Variable that will contain the Current Date as a simple line like.
11-2-2008
You can now take this and build a filename (Say a log file or a Datesensitive CSV?) like this
GET-QADGROUPMEMBER ‘Domain Admins’ | Select-Object DN,Name,SamAccountName | EXPORT-CSV C:\ReportFolder\$Logname+’-ImportantFile.CSV’
And now that you have THAT in your hands, you could SCHEDULE this as something rather than repeatedly doing it yourself (*Even if it IS cool to just type away in Powershell*)
Rock on and enjoy life with Powershell
Sean
The Energized Tech



.gif)
.gif)

Leave a comment