Introduction
Active Directory (AD) management helps system administrators control user access and resources easily. It keeps the network safe and organized.
Jump into concepts and practice - no test required
Active Directory (AD) management helps system administrators control user access and resources easily. It keeps the network safe and organized.
Import-Module ActiveDirectory Get-ADUser -Identity username Set-ADUser -Identity username -Enabled $false
Get-ADUser -Identity jsmith
Set-ADUser -Identity jsmith -Enabled $false
New-ADUser -Name "Jane Doe" -SamAccountName janed -AccountPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) -Enabled $true
This script checks if the user 'jsmith' exists in Active Directory. If found, it disables the user account and prints confirmation messages.
Import-Module ActiveDirectory # Check if user 'jsmith' exists $user = Get-ADUser -Identity jsmith -ErrorAction SilentlyContinue if ($user) { Write-Output "User 'jsmith' found." # Disable the user account Set-ADUser -Identity jsmith -Enabled $false Write-Output "User 'jsmith' has been disabled." } else { Write-Output "User 'jsmith' does not exist." }
Always test AD commands in a safe environment before running on live systems.
Disabling a user is safer than deleting, as it preserves data and settings.
Use proper permissions to run AD management commands.
AD management helps control who can access network resources.
PowerShell makes managing AD users and settings easier and faster.
Regular AD management keeps the network secure and organized.
Get-ADUser -Filter 'Enabled -eq $true' | Select-Object -ExpandProperty Name
Disable-ADUser -Identity $userName