?
Solved

Schedule Get-QADuser

Posted on 2012-08-31
12
Medium Priority
?
896 Views
Last Modified: 2012-09-07
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

0
Comment
Question by:AhmedAliShaik
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 18

Assisted Solution

by:Sushil Sonawane
Sushil Sonawane earned 300 total points
ID: 38356932
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
 
LVL 24

Assisted Solution

by:yo_bee
yo_bee earned 750 total points
ID: 38357122
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
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38357819
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
What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38357827
The second schedule task can be set to +30 mins after the first schedule completes
0
 
LVL 2

Author Comment

by:AhmedAliShaik
ID: 38358679
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
 
LVL 52

Assisted Solution

by:Manpreet SIngh Khatra
Manpreet SIngh Khatra earned 450 total points
ID: 38358687
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
 
LVL 2

Author Comment

by:AhmedAliShaik
ID: 38358691
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
 
LVL 52

Assisted Solution

by:Manpreet SIngh Khatra
Manpreet SIngh Khatra earned 450 total points
ID: 38358697
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
 
LVL 24

Accepted Solution

by:
yo_bee earned 750 total points
ID: 38358804
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
 
LVL 2

Author Comment

by:AhmedAliShaik
ID: 38358806
Thanks Yo_bee.

Will try and post you.
0
 
LVL 24

Expert Comment

by:yo_bee
ID: 38358813
Made a mistake.  It is ConvertTo-CSV .  I left that out.
0
 
LVL 2

Author Closing Comment

by:AhmedAliShaik
ID: 38375925
Thanks all.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Loops Section Overview

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question