Skip to main content

PowerShell New-ADComputer: Create AD Computer Objects Guide

β€’ 2 min read
powershell active-directory new-adcomputer computer-management tutorial

PowerShell New-ADComputer: Complete Guide to Creating AD Computer Objects

Overview

The New-ADComputer cmdlet creates new computer accounts in Active Directory. It’s used to prestage computers before joining the domain or to create computer objects for non-domain resources.

Common Tasks:

  • Prestage computer accounts before deployment
  • Create computer objects in specific OUs
  • Pre-configure computer properties
  • Set permissions before deployment
  • Organize computers by location/type

Prerequisites:

  • PowerShell 5.1 or later
  • Active Directory PowerShell module
  • Administrator permissions for the OU
  • Target OU must exist

Syntax

New-ADComputer [-Name] <string> [-SamAccountName <string>] [-Path <string>] [-Enabled <bool>] [-Description <string>]
```powershell

### Key Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `-Name` | String | Computer display name |
| `-SamAccountName` | String | Pre-Windows 2000 name (max 15 chars) |
| `-Path` | String | OU distinguished name where to create |
| `-Enabled` | Boolean | Enable account immediately (default: false) |
| `-Description` | String | Computer description |

---

## Examples

### Example 1: Prestage Basic Computer

```powershell
New-ADComputer -Name "WS-NYC-001" -SamAccountName "WS-NYC-001"
```powershell

**Result:** Creates computer object in default computers container

### Example 2: Prestage in Specific OU

```powershell
$ouPath = "OU=Workstations,OU=Computers,DC=contoso,DC=com"
New-ADComputer -Name "WS-NYC-001" -SamAccountName "WS-NYC-001" -Path $ouPath
```powershell

**Result:** Creates computer in specific OU

### Example 3: Prestage with Description

```powershell
$ouPath = "OU=Workstations,OU=Computers,DC=contoso,DC=com"
New-ADComputer -Name "WS-NYC-001" `
    -SamAccountName "WS-NYC-001" `
    -Path $ouPath `
    -Description "Workstation for NYC office - User TBD"
```powershell

**Result:** Prestages computer with descriptive information

### Example 4: Bulk Prestage Computers

```powershell
$ouPath = "OU=Workstations,OU=Computers,DC=contoso,DC=com"

for ($i = 1; $i -le 10; $i++) {
    $name = "WS-NYC-$('{0:D3}' -f $i)"
    New-ADComputer -Name $name -SamAccountName $name -Path $ouPath
    Write-Host "Created: $name"
}
```powershell

**Result:** Creates 10 computer objects (WS-NYC-001 through WS-NYC-010)

### Example 5: Prestage from CSV

```powershell
$csv = Import-Csv "C:\computers.csv"
$ouPath = "OU=Workstations,OU=Computers,DC=contoso,DC=com"

foreach ($item in $csv) {
    New-ADComputer -Name $item.Name `
        -SamAccountName $item.Name `
        -Path $ouPath `
        -Description $item.Location
    Write-Host "Created: $($item.Name)"
}
```powershell

**Result:** Prestages computers from CSV file

### Example 6: Server Prestaging

```powershell
$ouPath = "OU=Servers,OU=Computers,DC=contoso,DC=com"
New-ADComputer -Name "SRV-PROD-SQL01" `
    -SamAccountName "SRV-PROD-SQL01" `
    -Path $ouPath `
    -Description "Production SQL Server - Rack A3"
```powershell

**Result:** Prestages production server account

### Example 7: Computer with Enabled Account

```powershell
$ouPath = "OU=Workstations,OU=Computers,DC=contoso,DC=com"
New-ADComputer -Name "WS-NYC-001" `
    -SamAccountName "WS-NYC-001" `
    -Path $ouPath `
    -Enabled $true
```powershell

**Result:** Creates computer and enables immediately

### Example 8: Error Handling

```powershell
try {
    $ouPath = "OU=Workstations,OU=Computers,DC=contoso,DC=com"
    New-ADComputer -Name "WS-NYC-001" `
        -SamAccountName "WS-NYC-001" `
        -Path $ouPath `
        -ErrorAction Stop
    Write-Host "βœ“ Computer created successfully"
}
catch {
    if ($_.Exception.Message -like "*already exists*") {
        Write-Host "βœ— Computer already exists"
    }
    else {
        Write-Host "βœ— Error: $($_.Exception.Message)"
    }
}
```powershell

---

## Best Practices

βœ… **Prestage before deployment** - Set permissions in advance
βœ… **Use consistent naming** - Follows dept/location/number pattern
βœ… **Organize in OUs** - By location, type, or department
βœ… **Set descriptions** - Document computer purpose
βœ… **Verify OU exists** - Check path before creation

---

## Related Commands

- **[Get-ADComputer](/powershell-get-adcomputer)** - Query computers
- **[Set-ADComputer](/powershell-set-adcomputer)** - Modify computers
- **[Remove-ADComputer](/powershell-remove-adcomputer)** - Delete computers

---

## See Also

- **[Get-ADComputer](/powershell-get-adcomputer)** - Query computers
- **[Active Directory Computer Management](/active-directory-computer-management)** - Computer guide

---

**Last Updated:** February 6, 2026
**Difficulty Level:** Intermediate
**Reading Time:** 8 minutes