Change Computer Description

Hi All

Been digging about to find a script to change an Computer Object Description from a TXT file.

Would be looking at Having column A as the Computer name and Column B as the description

Im guessing Get-ADObject would get the description but not sure how to change (Very New to powershell)

Thanks

Dan

You should keep searching. There are thousands of examples for tasks like this available even here on Powershell.org.

The get an AD computer object you can use Get-ADComputer and to set an AD computer object you can use Set-ADComputer. I assume your TXT file is actually a CSV file. So you can use Import-CSV to read the content. Then you use a loop either with foreach or Foreach-Object to glue everything together. :wink:

Please, always read the complete help including the examples for the cmdlets you’re about to use to learn how to use them. Another great source for scripts or modules is the PowershelLGallery or StackOverflow. You can learn how to code in Powershell when you analyze the code others share with the world.

For the record, there is nothing that needs moderation in Olaf’s reply - which was helpful, and strewn with links to further reading.

They correctly suggest that OP might:

  • Import the text file using Import-CSV
  • Loop through each record using foreach or ForEach-Object
  • Use Set-ADComputer (which has a Description parameter) to modify the descriptions

If there are still issues, post the code here and folk will be able to help.

Hi This is the code below

CSV format is

Name, Description

Get-Content 'C:\Temp\Test\Test Description.csv' |
ForEach {
    Get-ADComputer $PSItem.Name |
    Set-ADComputer $PSItem.Name -Description $PSItem.Description
}

 

 

 

`

Did you actually read my answer? Get-Content -> Import-CSV !!! And you actually don’t need Get-ADComputer when your CSV file contains the correct name of the computer account.

`Import-Module ActiveDirectory
Import-CSV "Enter File Path Here" | % {
$Computer = $_.ComputerName
$Desc = $_.Description
Set-ADComputer $Computer -Description $Desc
}`

 

 

Got it working through this way thanks for the help