Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Windows s2k3 script help

  • 07-08-2007 5:16pm
    #1
    Registered Users, Registered Users 2 Posts: 782 ✭✭✭


    Hi All,
    I am trying to write some scripts Windows scripts or VBS scripts to do the following.

    1. Take input of NT username from CSV file and then disable the account in windows (using dsuser -disable command i think)
    2. Take input of NT username and other details like home drive etc from CSV file, remove user from all groups, delete the user, delete the home drive etc...

    Any ideas where to start please?
    Cheers,
    M


Comments

  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,407 Mod ✭✭✭✭Capt'n Midnight


    %%A would be the username from a For /F import of the csv delims=,

    IIRC
    net.exe user %%A /delete /domain
    If you delete the user they are automatically removed from all groups.

    rmdir %%a /S /Q
    rd or rmdir will remove folders without asking for questions

    there is this too
    net user username /expire:12/01/99


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    You can use CSVDE to import a user account and disable it

    http://technet2.microsoft.com/windowsserver/en/library/1050686f-3464-41af-b7e4-016ab0c4db261033.mspx?mfr=true

    You can also you use AD scripting with VBS and use the ReadLine

    Pseudo

    open CSV file

    Readline

    Split into correct vars

    Get NT Users

    Search AD for homedir etc
    DELETE them
    DELETE a/c or just move them to a cleanup OU and disable them so you can inspect them before deleting them

    Repeat till end of file


  • Registered Users, Registered Users 2 Posts: 782 ✭✭✭gibo_ie


    Ginger wrote:
    You can use CSVDE to import a user account and disable it

    http://technet2.microsoft.com/windowsserver/en/library/1050686f-3464-41af-b7e4-016ab0c4db261033.mspx?mfr=true

    You can also you use AD scripting with VBS and use the ReadLine

    Pseudo

    open CSV file

    Readline

    Split into correct vars

    Get NT Users

    Search AD for homedir etc
    DELETE them
    DELETE a/c or just move them to a cleanup OU and disable them so you can inspect them before deleting them

    Repeat till end of file

    Thanks guys,
    This is exactly what i want to do. All i need now is somebody who is good at scripting to give me a push on with it. There is a few pints in it for them too :)
    Cheers,
    M


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    I don't have access to an AD domain that I can screw around with here, but I can put a framework in place for you.

    What kind of format would the CSV file be in? Would it be like
    username1,username2,username3,username4,username5
    
    or
    username1
    username2
    username3
    username4
    username5
    
    ?


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    It comes in pints?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 782 ✭✭✭gibo_ie


    seamus wrote:
    I don't have access to an AD domain that I can screw around with here, but I can put a framework in place for you.

    What kind of format would the CSV file be in? Would it be like
    username1,username2,username3,username4,username5
    
    or
    username1
    username2
    username3
    username4
    username5
    
    ?
    Thanks Seamus.
    I would be getting in a CSV file in
    username1,email,staffID,homeDir
    

    then each new line would have the next user to be done....

    @ginger: Yep no cash so a few pints to whoever can help as a bit of thanks! :)


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    should be a quick lookup using ADSI to do this..

    Something like this

    http://www.computerperformance.co.uk/ezine/ezine134.htm

    Dont use these scripts as is, but just to look at how to do it

    Anyways some more code
    On Error Resume Next
    Set objUser = GetObject _
      ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
    objUser.GetInfo
     
    strProfilePath = objUser.Get("profilePath")
    strScriptPath = objUser.Get("scriptPath")
    strHomeDirectory = objUser.Get("homeDirectory")
    strHomeDrive = objUser.Get("homeDrive")
     
    WScript.echo "profilePath: " & strProfilePath
    WScript.echo "scriptPath: " & strScriptPath
    WScript.echo "homeDirectory: " & strHomeDirectory
    WScript.echo "homeDrive: " & strHomeDrive
    
    

    That gets things like homedire and all that so you can delete it
    'Deleting a User Account from Active Directory
    
    'Deletes the user account for MyerKen from the HR organizational unit in a hypothetical domain named fabrikam.com. 
    
    Set objOU = GetObject("LDAP://ou=hr,dc=fabrikam,dc=com")
    objOU.Delete "user", "cn=MyerKen"
    
    
    


Advertisement