Windows 2019
Sponsored Link

Active Directory : Add Computer Accounts(CUI)2019/02/27

 
Add Computer Accounts with Commands on CUI.
[1] Run PowerShell or Command Prompt and use [dsadd computer] command.
# show current computer list
PS C:\Users\Administrator> dsquery computer -name * 
"CN=FD3S,OU=Domain Controllers,DC=srv,DC=world"
"CN=RX-5,CN=Computers,DC=srv,DC=world"

# for example, add a computer [RX-7] under the [Computers]
PS C:\Users\Administrator> dsadd computer CN=RX-7,CN=Computers,DC=srv,DC=world 
dsadd succeeded:CN=RX-7,CN=Computers,DC=srv,DC=world

PS C:\Users\Administrator> dsquery computer -name RX-7 
"CN=RX-7,CN=Computers,DC=srv,DC=world"


# options for [dsadd computer]
PS C:\Users\Administrator> dsadd computer /? 

Description: Adds a computer to the directory.

Syntax:  dsadd computer <ComputerDN> [-samid <SAMName>] [-desc <Description>]
        [-loc <Location>] [-memberof <Group ...>]
        [{-s <Server> | -d <Domain>}] [-u <UserName>]
        [-p {<Password> | *}] [-q] [{-uc | -uco | -uci}]

.....
.....
[2] If you'd like to delete Computer Accounts, use [dsrm] command.
# for example, delete a computer [RX-7]
PS C:\Users\Administrator> dsquery computer -name RX-7 
"CN=RX-7,CN=Computers,DC=srv,DC=world"

PS C:\Users\Administrator> dsrm "CN=RX-7,CN=Computers,DC=srv,DC=world" 
Are you sure you wish to delete CN=RX-7,CN=Computers,DC=srv,DC=world (Y/N)? y
dsrm succeeded:CN=RX-7,CN=Computers,DC=srv,DC=world
[3] If you use PowerShell, It's possible to use Cmdlet for PowerShell.
# show current computer list
PS C:\Users\Administrator> Get-ADComputer -Filter * | Format-Table DistinguishedName 

DistinguishedName
-----------------
CN=FD3S,OU=Domain Controllers,DC=srv,DC=world
CN=RX-7,CN=Computers,DC=srv,DC=world

# for example, add a computer [RX-9]
PS C:\Users\Administrator> New-ADComputer -Name RX-9 

# verify
PS C:\Users\Administrator> Get-ADComputer -Filter * | Format-Table DistinguishedName 

DistinguishedName
-----------------
CN=FD3S,OU=Domain Controllers,DC=srv,DC=world
CN=RX-7,CN=Computers,DC=srv,DC=world
CN=RX-9,CN=Computers,DC=srv,DC=world

# for adding computer with some parameters like OU or admin account
PS C:\Users\Administrator> New-ADComputer -Name RX-8 `
-Path "OU=Computers,OU=Hiroshima,DC=srv,DC=world" `
-ManagedBy "CN=Serverworld,CN=Users,DC=srv,DC=world" 


# if delete, do like follows
PS C:\Users\Administrator> Remove-ADComputer -Identity "CN=RX-9,CN=Computers,DC=srv,DC=world" 

Confirm
Are you sure you want to perform this action?
Performing the operation "Remove" on target "CN=RX-9,CN=Computers,DC=srv,DC=world".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y


# options for [New-ADComputer]
PS C:\Users\Administrator> Get-Help New-ADComputer 

NAME
    New-ADComputer

SYNOPSIS
    Creates a new Active Directory computer.


SYNTAX
    New-ADComputer [-Name] <String> [-AccountExpirationDate <DateTime>] [-AccountNotDelegated <Boolean>] [-AccountPassw
    ord <SecureString>] [-AllowReversiblePasswordEncryption <Boolean>] [-AuthenticationPolicy <ADAuthenticationPolicy>]
     [-AuthenticationPolicySilo <ADAuthenticationPolicySilo>] [-AuthType {Negotiate | Basic}] [-CannotChangePassword <B
    oolean>] [-Certificates <X509Certificate[]>] [-ChangePasswordAtLogon <Boolean>] [-CompoundIdentitySupported <Boolea
    n>] [-Credential <PSCredential>] [-Description <String>] [-DisplayName <String>] [-DNSHostName <String>] [-Enabled
    <Boolean>] [-HomePage <String>] [-Instance <ADComputer>] [-KerberosEncryptionType {None | DES | RC4 | AES128 | AES2
    56}] [-Location <String>] [-ManagedBy <ADPrincipal>] [-OperatingSystem <String>] [-OperatingSystemHotfix <String>]
    [-OperatingSystemServicePack <String>] [-OperatingSystemVersion <String>] [-OtherAttributes <Hashtable>] [-PassThru
    ] [-PasswordNeverExpires <Boolean>] [-PasswordNotRequired <Boolean>] [-Path <String>] [-PrincipalsAllowedToDelegate
    ToAccount <ADPrincipal[]>] [-SAMAccountName <String>] [-Server <String>] [-ServicePrincipalNames <String[]>] [-Trus
    tedForDelegation <Boolean>] [-UserPrincipalName <String>] [-Confirm] [-WhatIf] [<CommonParameters>]

.....
.....
Matched Content