๐ฅ๏ธ Computer Account Management (PowerShell)
PowerShell commands for managing computer accounts in Active Directory. Useful for provisioning, cleanup, and auditing.
โ Create a New Computer Account
New-ADComputer -Name "PC-001" -Path "OU=Computers,DC=example,DC=com" -Enabled $true
๐ Rename a Computer Account
Rename-ADObject -Identity "CN=OldName,OU=Computers,DC=example,DC=com" -NewName "NewName"
๐ข Move Computer to Another OU
Move-ADObject -Identity "CN=PC-001,OU=OldOU,DC=example,DC=com" -TargetPath "OU=NewOU,DC=example,DC=com"
โ Disable or Delete a Computer Account
Disable
Disable-ADAccount -Identity "PC-001"
Delete
Remove-ADComputer -Identity "PC-001" -Confirm:$false
๐ Find Inactive Computer Accounts
Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan 90.00:00:00
๐ List All Computers in a Specific OU
Get-ADComputer -Filter * -SearchBase "OU=Computers,DC=example,DC=com"
๐งช Get Computer Details
Get-ADComputer -Identity "PC-001" -Properties *
๐งผ Cleanup: Find Disabled Computer Accounts
Get-ADComputer -Filter 'Enabled -eq $false'
๐ Export List of Computers to CSV
Get-ADComputer -Filter * -Property Name,OperatingSystem |
Select-Object Name,OperatingSystem |
Export-Csv -Path ".\Computers.csv" -NoTypeInformation