Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Need help to build a script

  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help to build a script


    I have a periodic task which requires me disable users, who have not logged in for 90 days or so and move them to a seperate OU. The environment is very big so the user list is also very long.

    After I generate this list I have to run 'dsquery -name "user name" ' to get the OU information of each user before I disable them. This is on Windows 2003 Domain.

    Is there a way for me to run a bulk query with all user names at once and export the results to an excel sheet. Maybe using Powershell. I am not very good at scripting but can make sense of scripts.

    Any help is greatly appreciated.



  • #2
    Re: Need help to build a script

    First hot on Google gives this


    • #3
      Re: Need help to build a script

      Thanks a lot and sorry for the late reply. Got caught up with other things. I will give this a try.


      • #4
        Re: Need help to build a script

        Note, the lastLogon attribute (what is used in the sample script) is not replicated in Active Directory, a different value can be stored in the copy of Active Directory on each Domain Controller! If you have multiple domain controllers in your environment, the script should query each DC first and find the most recent lastLogon value (sample: cscript //nologo LastLogon.vbs > output.txt 2>&1).

        Becareful not to move administrative acccounts (i.e. accounts used to perform LDAP queries)


        This posting is provided "AS IS" with no warranties, and confers no rights.


        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts