Exporting AD entries to csv file

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 3 months ago.

  • Author
    Posts
  • #5247

    by jhaighsy at 2012-10-30 06:04:02

    Hi, I've created a script which pulls User details from AD and puts them in a csv file. I want to auto run this script every month so to do this I have created a task schedule to run a batch file of the powershell script.

    The problem I have is that the csv file is being overwritten each time the script runs. I want it so that a new csv file is created each time and named differently.

    I'm new to all of this so not sure where to go with it.

    My script is:

    Add-PSSnapin Quest.ActiveRoles.ADManagement
    Get-QADUser -SizeLimit 0 | Select-Object lastname,firstname,email | Export-Csv c:\PSexport\Allusers.csv -NoTypeInformation

    Any ideas?

    by iHunger at 2012-10-30 06:16:28

    $today = Get-Date -Format ymmdd
    Add-PSSnapin Quest.ActiveRoles.ADManagement
    Get-QADUser -SizeLimit 0 | Select-Object lastname,firstname,email | Export-Csv c:\PSexport\Allusers$today.csv -NoTypeInformation

    by jhaighsy at 2012-10-30 06:23:10

    Thanks very much for that! Works a treat 🙂

You must be logged in to reply to this topic.