Bulk Enable Active Directory User Accounts
Managing Active Directory user accounts efficiently is crucial for maintaining security and usability within an organization. This PowerShell script allows administrators to bulk enable user accounts that may have been disabled, making it easier to manage user access as needed.
At ServerEngine, we provide powerful tools to streamline your server management tasks. Visit [ServerEngine](https://serverengine.co) to learn more about our software solutions.
### Step 1: Import the Active Directory Module
Ensure that you have the Active Directory module available and imported in your PowerShell session before executing the script.
“`powershell
Import-Module ActiveDirectory
### Step 2: Prepare Your CSV File
Create a CSV file containing the usernames or SamAccountNames of the disabled user accounts you wish to enable. The file should have a header named `UserName`.
Example `enable_users.csv`:
“`
UserName
jdoe
jsmith
“`
### Step 3: Define the Function to Enable Users
Next, we will create a function named `Enable-ADUserAccounts` that reads the CSV file and enables each user account listed.
“`powershell
function Enable-ADUserAccounts { param ( [string]$csvPath ) $users = Import-Csv -Path $csvPath foreach ($user in $users) { $username = $user.UserName try { Enable-ADAccount -Identity $username Write-Host "Successfully enabled user: $username" } catch { Write-Host "ERROR: Could not enable user: $username. Error: $_" } } }
### Step 4: Execute the Enable Users Function
Now, you can run the function, providing the path to your CSV file where the disabled user accounts are listed.
“`powershell
Enable-ADUserAccounts -csvPath "C:\Path\To\Your\enable_users.csv"
### Conclusion
This PowerShell script simplifies the process of bulk enabling Active Directory user accounts, facilitating better user management. For more innovative IT management solutions, explore what we offer at [ServerEngine](https://serverengine.co).