Active Directory User Unlocker [ADSI] (WinForm GUI)

The following script will show how to Unlock Active Directory User account using PowerShell The goal is to do something simple and functional, no fancy GUI... No need of Active Directory Module or Quest Active Directory Snapin, in my case I used ADSI: [ADSISearcher]

 
 
 
 
 
4.6 Star
(7)
5,196 times
Add to favorites
Active Directory
10/25/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Account Disabled code
    2 Posts | Last post March 31, 2015
    • Bonjour Francois,
      
      I have modified the script to also allow for a check if the account is disabled.
      
      $buttonDisabledCheck_Click = {
      
      # Get the Current text in $textbox1
      $name = $textbox1.Text
      
      # Search for this account in the current domain
      $Searcher = [ADSISearcher]"(sAMAccountName=$Name)"
      $Results = $Searcher.FindOne()
      
      # Get the current date and time
      $DateFormat = Get-Date -Format "yyyy/MM/dd-HH:mm:ss"
      
      if ($Results -ne $null)
      {
      # If an Account is found do the following
      
      # Here we check the property "AccountDisabled", if it is greater that 0
      # this mean the account is Disabled
      if ($Results.GetDirectoryEntry().InvokeGet('AccountDisabled'))
      {
      # Show the information in the ListBox
      Load-ListBox `
      -ListBox $listBox1 `
      -Items "$DateFormat - $name - Account Disabled" `
      -Append
      }
      else
      {
      # Show the information in the ListBox
      Load-ListBox `
      -ListBox $listBox1 `
      -Items "$DateFormat - $name - Account NOT Disabled!" `
      -Append
      }
      }
      else
      {
      # Show the information in the ListBox
      Load-ListBox `
      -ListBox $listbox1 `
      -Items "$DateFormat - $name - Account Not Found!" `
      -Append
      }
      }#$buttonDisabledCheck_Click
      
      Thought this might be helpful...
      
      Regards
      Steve
    • Thanks for sharing Steve!
      As mentionned on my blog comment I'm working on a new version and will include the Disabled/Enabled state of the account :-)
      
      Thanks for your feedback, appreciated!