+ Post New Thread
Results 1 to 6 of 6
Windows Server 2008 R2 Thread, Disable user - Until they log in again in Technical; Is there any way to disable a load of user accounts but automatically have them enable again once the user ...
  1. #1

    Join Date
    Jan 2007
    Posts
    993
    Thank Post
    15
    Thanked 48 Times in 28 Posts
    Rep Power
    25

    Disable user - Until they log in again

    Is there any way to disable a load of user accounts but automatically have them enable again once the user enters their correct username and password?

    We're 'not allowed' to simply wipe all the student accounts and start fresh any more due to how our courses no longer seem to stick to simple academic years (Apprentices etc confuse matters!) so I was thinking disable the lot of them and the ones which haven't logged back in after a set date in late September / October can be deleted.

  2. #2
    jonawd's Avatar
    Join Date
    Dec 2009
    Location
    Hayfield, High Peak
    Posts
    45
    Thank Post
    4
    Thanked 8 Times in 7 Posts
    Rep Power
    12
    Not that I know... If your looking to find users who haven't used their accounts though, can you use the 'lastLogon' and 'lastLogonTimeStamp' attributes in AD to work that out?

  3. #3

    Join Date
    Oct 2005
    Location
    hey hey hey, stay outta my shed. STAY OUT OF MY SHED.
    Posts
    1,099
    Thank Post
    265
    Thanked 221 Times in 167 Posts
    Rep Power
    112
    What precise functionality will you get from "Disabling them until they log back in again" that isn't granted by just, y'know, leaving them?

  4. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,323
    Thank Post
    903
    Thanked 1,802 Times in 1,551 Posts
    Blog Entries
    12
    Rep Power
    467
    Quote Originally Posted by Roberto View Post
    What precise functionality will you get from "Disabling them until they log back in again" that isn't granted by just, y'know, leaving them?
    I am confused as well. Also what is gained from Deleting all the students accounts?

  5. #5

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,631
    Thank Post
    747
    Thanked 1,707 Times in 1,520 Posts
    Rep Power
    437
    The ones that were reactivated in Sept by them logging in would then be an easy indicator of the active accounts.

    But no you can't you'll have to deactivate them all and reactivate the ones that come and ask.

    Ben

  6. #6

    Join Date
    Dec 2007
    Location
    Potomac, MD, USA
    Posts
    68
    Thank Post
    12
    Thanked 28 Times in 14 Posts
    Rep Power
    56
    Just leave them on and query by last logon time come September. This PowerShell script should find all the accounts that haven't logged in in 30 days and disable them:

    Code:
    $daysInactive = 30  
    $time = (Get-Date).Adddays(-($daysInactive))
    
    Get-ADUser -Filter {LastLogonTimeStamp -lt $time} -SearchBase "OU=Students,DC=yourdomain,OU=internal" | Disable-ADAccount
    Note that this uses the lastLogonTimeStamp attribute, which has 2 caveats: it only gets populated on 2003 level domains and higher, and it is only guaranteed to be accurate if the user's last logon was 14 days or more in the past.



SHARE:
+ Post New Thread

Similar Threads

  1. Single user can't log in to RDS - hangs at "Welcome" screen
    By localzuk in forum Thin Client and Virtual Machines
    Replies: 1
    Last Post: 7th February 2013, 12:53 PM
  2. Replies: 23
    Last Post: 15th May 2012, 05:55 PM
  3. Scheduled Task - user must be logged in to run
    By enjay in forum Windows Server 2008 R2
    Replies: 12
    Last Post: 17th January 2012, 05:29 PM
  4. Replies: 2
    Last Post: 18th November 2009, 10:36 PM
  5. New users can't log in to Outlook Web Access
    By WithoutMotive in forum Windows
    Replies: 5
    Last Post: 7th September 2007, 12:17 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •