AD Computer mail and description attributes bulk update using csv file

Chetan Gawali 1 Reputation point
2023-03-08T16:58:34.4533333+00:00

AD Computer mail and description attributes bulk update using csv file

thanks in advance

Chetan

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Fabricio Godoy 2,611 Reputation points
    2023-03-08T18:23:00.74+00:00

    Hello @Chetan Gawali

    I believe you are looking for this:

    # Import the CSV file containing the computer name, email, and description columns
    $computers = Import-Csv -Path "C:\path\to\computers.csv"
    
    # Loop through each computer in the CSV file
    foreach ($computer in $computers) {
    
      # Get the AD computer object by the computer name
      $adComputer = Get-ADComputer -Identity $computer.Name
      
      # Update the email and description attributes
      Set-ADComputer -Identity $adComputer -EmailAddress $computer.Email -Description $computer.Description
      
      # Output the updated computer name, email, and description
      Write-Host "Updated $($adComputer.Name) with email $($computer.Email) and description $($computer.Description)"
      
    }
    
    

    Ensure the CSV have: Name, Email, and Description columns

    I hope this help you.

    Regards


  2. Rich Matheisen 47,766 Reputation points
    2023-03-10T16:21:44.5766667+00:00

    The AD Computer object type doesn't have an "emailaddress" property. You can set the "description" and put an email object into the description property. Or you can set the computers "ManagedBy" property to an individual user or, perhaps, to a distribution list.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.