Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Create a Computer Account in Active Directory Using New-ADComputer

In a Windows environment, managing Active Directory (AD) is a crucial task for system administrators. One of the common tasks is creating computer accounts in AD, which can be efficiently done using the New-ADComputer cmdlet in PowerShell. This cmdlet allows administrators to automate the process of adding new computers to the domain, ensuring consistency and saving time. This article will guide you through the process of using the New-ADComputer cmdlet to create computer accounts in Active Directory.

Examples:

  1. Basic Example: Creating a New Computer Account

    To create a new computer account in a specific Organizational Unit (OU), use the following command:

    New-ADComputer -Name "ComputerName" -SamAccountName "ComputerName" -Path "OU=Computers,DC=example,DC=com"

    In this example, replace "ComputerName" with the name of the computer you want to add, and adjust the -Path parameter to point to the correct OU in your AD structure.

  2. Adding Additional Properties

    You can also specify additional properties such as description, location, and more:

    New-ADComputer -Name "ComputerName" -SamAccountName "ComputerName" -Path "OU=Computers,DC=example,DC=com" -Description "Test Computer" -Location "Building 1"
  3. Creating Multiple Computer Accounts

    To create multiple computer accounts, you can use a loop in PowerShell:

    $computers = @("Comp1", "Comp2", "Comp3")
    foreach ($computer in $computers) {
       New-ADComputer -Name $computer -SamAccountName $computer -Path "OU=Computers,DC=example,DC=com"
    }
  4. Using Secure Strings for Passwords

    If you need to set a password for the computer account, you can use a secure string:

    $password = Read-Host "Enter Password" -AsSecureString
    New-ADComputer -Name "ComputerName" -SamAccountName "ComputerName" -Path "OU=Computers,DC=example,DC=com" -AccountPassword $password
  5. Verifying the Creation

    After creating the computer account, you can verify its existence using the Get-ADComputer cmdlet:

    Get-ADComputer -Identity "ComputerName"

    This command will display the details of the newly created computer account.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.