I can´t seem to get this script to work, it should add text if there are anything written in the description.
It somehow always overwrite whatever is there.
Any suggestions how i can fix this?
Thanks in advance \ Thomas
Import-Module activedirectory
Define the path to the file containing AD computer names
foreach ($computer in $computersToDisable) {
# Get the current description of the computer
$currentDescription = (Get-ADComputer -Identity $computerName).Description
# Concatenate the new text with date and time to the current description
$newDescription = "$currentDescription`nDisabled on $currentDateTime"
# Set the new description for the computer
Set-ADComputer -Identity $computerName -Description $newDescription
Firstly, when posting code in the forum, please can you use the preformatted text </> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working). If you can’t see the </> in your toolbar, you will find it under the gear icon.