Schedule Get-QADuser

We are generating a report with list of users who has created newly within 7 days with QAD cmdlet.

Going to create batch file and schedule weekly once to execute.

Can we add time in the script so that it starts collecting the report from

Monday 7:00 AM to next Monday 6:59 AM

This requirement is to avaoid overlapping. Please guide me.
Get-QADUser -CreatedAfter (Get-Date).AddDays(-7) -IncludeAllProperties | select Samaccountname,displayname,description,whencreated,useraccountcontrol | Export-Csv -Path c:\Report.csv

Open in new window

LVL 2
AhmedAliShaikAsked:
Who is Participating?
 
yo_beeConnect With a Mentor Director of Information TechnologyCommented:
Try this and see if it will appends If it does then you can save it as ps1 file then schedule it for a daily run.


Get-QADUser -CreatedAfter (Get-Date).AddDays(-7) -IncludeAllProperties | select Samaccountname,displayname,description,whencreated,useraccountcontrol | ConvertTo | Out-file -filepath c:\Report.csv -append

Open in new window

0
 
Sushil SonawaneConnect With a Mentor Commented:
Please refer below link.
(http://www.ldapsoft.com/adreportdetails.html)


Active Directory All Objects Created in Last 7 Days Report

All Objects Created in Last 7 Days report is created using the following sqlldap statement
 Selectcn,creatorsName,createTimeStamp,modifiersName,modifyTimeStamp,sAMAccountName,userAccountControl from RootDSE where createTimestamp >= CurrentTimestamp -7 days subtreescope
0
 
yo_beeConnect With a Mentor Director of Information TechnologyCommented:
Since you have the script in place why not use Task Scheduler to run this in a time frame you like.
First save your script as a .ps1 file (Open Notepad and copy and paste your script, then save as ps1 file.) Example New_ADOBJECTS.PS1

Once saved Open Task Schduler:
http://technet.microsoft.com/en-us/library/cc721871.aspx
Triggers: This is the time you want it to run.
http://technet.microsoft.com/en-us/library/cc748841.aspx
Actions: This is the task you want to run. For yours you will run powershell.exe NEW_ADOBJECT.PS1
Actionhttp://technet.microsoft.com/en-us/library/cc722129.aspx

How To:
http://technet.microsoft.com/en-us/library/cc766428.aspx
This is also a nice How To.  Even though is from a Windows 7 forum it is the same for Windows Server 2008
http://www.sevenforums.com/tutorials/12444-task-scheduler-create-new-task.html
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
What i can think of is get a command to run and extract the list ...... now create a second Schedular to email the script and rename with date extenstion.

SO once you have the list in email even if its overwritten it wouldnt make much of a difference  .... Right

- Rancy
0
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
The second schedule task can be set to +30 mins after the first schedule completes
0
 
AhmedAliShaikAuthor Commented:
Hi Sushil : in our environment we are not supposed to use 3rd party tools unless we cant do it from script. But thanks a lot for sharing the tool.

Hi Yo_bee ,

Hi Rancy,

I am really sorry as my question is not clear.

Let me tell one example:

users objects are created from monday 09/03/2012 6:00 AM to next week ie 09/10/12  11:00 AM.

When i run the report the script should pull only objects that are created from monday 6:00 Am to next Monday 5:59 AM. All the objects which are created after 5:59 AM has to be pulled in the next week report.

Can we fine tune the script to pull a report as per my requirement.
0
 
Manpreet SIngh KhatraConnect With a Mentor Solutions Architect, Project LeadCommented:
You want the data to keep appending ?

What i was saying is lets say today the script runs it will give you for last 7 days and email you the data .... again next week it will again run for last 7 days and email you so in that way you have the data on Email and you can check whatever you want and can combine the any number of csv files with a simple command.

- Rancy
0
 
AhmedAliShaikAuthor Commented:
Yep,

My concern is when i run script for the second time i will get overlapping objects.

Wanna avoid overlapping objects in the second file.
0
 
Manpreet SIngh KhatraConnect With a Mentor Solutions Architect, Project LeadCommented:
I am not sure as you say to add the data from next week rather than overrite .....

Lets see if this can work.
Your script maybe has some thing where it says create file with Date extension in the end and then in the same script or another it says to run a command on a folder csv files to merge them.

- Rancy
0
 
AhmedAliShaikAuthor Commented:
Thanks Yo_bee.

Will try and post you.
0
 
yo_beeDirector of Information TechnologyCommented:
Made a mistake.  It is ConvertTo-CSV .  I left that out.
0
 
AhmedAliShaikAuthor Commented:
Thanks all.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.