Hi Scripting Expert! Need a script to query last logon user from registry and get it's domain group

Answered Hi Scripting Expert! Need a script to query last logon user from registry and get it's domain group

  • Wednesday, December 12, 2012 7:49 AM
     
     

    hi,

    I need a logon script to query last logon user from registry. Once the user information is collected. The script make a check which group does the user belongs to. If it belongs to a certain group, the script will map the user respective DFS Drive

All Replies

  • Wednesday, December 12, 2012 9:32 AM
     
     
    Sorry, this is not a free code dispensing service. After you have written the script yourself, feel free to post it here and ask for advice about specific problems or issues.
  • Wednesday, December 12, 2012 10:00 AM
     
     
    Noted. I am not familiar with scripting. Any help or reference link is greatly appreciated.
  • Wednesday, December 12, 2012 11:03 AM
     
     

    hi,

    I need a logon script to query last logon user from registry. Once the user information is collected. The script make a check which group does the user belongs to. If it belongs to a certain group, the script will map the user respective DFS Drive

    This is not really a scripting issue.  You should ask your Domain Admins how to do this or have them set it up for you.  It is a technical configuration issue that can only be done by the Domain Admins using GP. I know you have bee led to believe that we do this by script but that hasn't been necessary since WS2003R2.

    I recommend learning how to administer Windows.  There are many videos on the MS Windows site that will help you get started.  You can learn scripting by clicking the "Learn" link above.

    Note that the last logged on user is not kept in the registry.  I think what you are asking is for the "current" logged in user.  The current user is %username% from a batch file or at a CMD prompt.  Knowing basic Windows would have allowed you to do know this.

    \


    ¯\_(ツ)_/¯

  • Thursday, December 13, 2012 7:18 AM
     
     

    hi jrv,

    it is partly true. All domain users has read access to AD. I used the following powershell, courtesy of Francois-Xavier and I was able to monitor group member status of a particular group.

    http://gallery.technet.microsoft.com/scriptcenter/Monitor-Active-Directory-4c4e04c7#content

    thanks!

  • Thursday, December 13, 2012 9:28 AM
     
     Answered

    Logon scripts are executed via Group Policy and not by a user.  They are run in the user's context during logon.  Why do you want to query the registry?

    In Windows we use Policy to bind scripts to users and groups.  In Windows 2008 and later we use Group Policy Preferences to map drives. This is preferred and easy to  manage.


    ¯\_(ツ)_/¯