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!
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!