Need help with CSVDE

Joined
Aug 28, 2009
Messages
3
Reaction score
0
I found this post on another section of this board:

CSVDE export of users: how to make whenCreated query the currentda
I'm exporting users in AD using CSVDE command line base on a manual query
where user is created Today.

QUESTION:
How to make the whenCreated query to use the current date without hardcoding
the day?

Sample Code:
CSVDE -f %date:~-4,4%%date:~-7,2%%date:~-10,2%.csv
"(&(objectClass=user)(whenCreated>=20090504000000.0Z)(whenCreated<=20090505000000.0Z))" -l "employeeID, sn, givenName, sAMAccountName"

where:
%date:~-4,4%%date:~-7,2%%date:~-10,2%.csv = today's date.csv (e.g.
20090504.csv)
(objectClass=user) = AD query will return user
(whenCreated>=20090504000000.0Z)(whenCreated<=20090505000000.0Z) = AD
query created today May 4, 2009
employeeID, sn, givenName, sAMAccountName = AD attributes that will be
exported in the .CSV file


My question is very similar, however I want to have the last 7 days worth, not just todays. There was one answer to the original question with code that works perfectly for just today (the following should be one single line):

CSVDE -f -%date:~-10,2%_%date:~-7,2%_%date:~-4,4%.csv -r
"(&(objectClass=user)(whenCreated>=%date:~-4,4%%date:~-10,2%%date:~-7,2%000000.0Z)(whenCreated<=%date:~-4,4%%date:~-10,2%%date:~-7,2%235959.0Z))"
-l "employeeID, sn, givenName, sAMAccountName"

How do I change this to use the last 7 days?

Thanks in advance for any help with this one!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top