PowerShell Reference

A growing library of PowerShell tools and patterns I've put together as a sysadmin. Public and open-source for anyone who wants to learn, copy, or contribute.

View on GitHub

๐Ÿ–ฅ๏ธ 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