Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I append or prepend the description in AD I want to leave the current description and put some text infront of it

for example a computer has the description as "Accounting Dept" (without quotes)

I tried this:

set-QADComputer -Identity computername
    -Description {Disabled 8/17/2012, Termrpt "$($_.description)"}

I get this for the description

Disabled 8/17/2012, "$($_.description)"

but I want the orginal description prepended by the text like the following

Disabled 8/17/2012, Accounting dept

any ideas?

I tried parentheses instead but then it just puts the prepended text and wipes out the original altogether.

share|improve this question

I don't use the QWEST AD cmdlets, so I don't know the exact syntax, but generally the best way is to retrieve the current description, save it to a variable, and then just write $Current_Desc + $addendum back to the object.

share|improve this answer

I don't use the Qwest modules. If you're willing to use the Microsoft AD module, included with RSAT, the following is pretty straightforward.

Import-Module ActiveDirectory

# Let's check the Description
Get-ADUser jscott -Properties Description |
  Select-Object -Property Description

Junior Keyboard MRO Tech

# Cool, set it the new value
Get-ADUser jscott -Properties Description |
  ForEach-Object {
    Set-ADUser $_ -Description "Disabled 8/17/2012, Termrpt $($_.Description)"

# Let's check the new Description
Get-ADUser jscott -Properties Description |
  Select-Object -Property Description

Disabled 8/17/2012, Termrpt Disabled Junior Keyboard MRO Tech

I think what's tripping you up is the usage of $_ as parameter of a cmdlet, rather than within a script block. I've wrapped Set-ADUser in a ForEach_Object, ensuring $_ is the object from the pipeline. Outside of a script block, as in your case, using $_ as a parameter will return $null.

share|improve this answer

In addition to MDMarra's answer (beat me to the punch), you can also set a string variable to be equal to an appended value with +=, so something like $Description += "blah" would append "blah" to the end of your variable value.

($Description += "blah" being short hand for $Description = $Description + "blah")

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.