# PLs Help need Bulk Disable Account but I need to compile Description field

**URL:** <https://forums.powershell.org/t/pls-help-need-bulk-disable-account-but-i-need-to-compile-description-field/11445>\
**Category:** PowerShell Help\
**Created:** [October 9, 2018, 10:43am UTC](https://forums.powershell.org/t/pls-help-need-bulk-disable-account-but-i-need-to-compile-description-field/11445 "2018-10-09T10:43:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![baoh](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@baoh](https://forums.powershell.org/u/baoh)\
**Post date:** [October 9, 2018, 10:43am UTC](https://forums.powershell.org/t/pls-help-need-bulk-disable-account-but-i-need-to-compile-description-field/11445/1 "2018-10-09T10:43:55Z")

</div>

Hi Guys,  
I’m in Active direcotory Win server and I need to do what i ask belove. I’m no soo good with script I find this code to disable and move account

“Get-Content D:\script\moveruser.csv | Get-ADUser | Move-ADObject -TargetPath “OU=test2,DC=contoso,dc=org” -PassThru | Disable-ADAccount”

but now the must difficult things for me is that:

I need to do for a list of account (have .cvs list): Copy what in the Object Tab (Canonical field), paste in the Description field but like the Example:  
In Description I have: “y.y”. I need to obtain: y.y + “origin” + paste what was in Object tab filed + “Disalbed xx/xx/2018”.

Pls help txxx

sorry for my english 😉

---

<div class="post-metadata">

**Author:** ![devilsbane](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@devilsbane](https://forums.powershell.org/u/devilsbane)\
**Post date:** [October 9, 2018, 3:21pm UTC](https://forums.powershell.org/t/pls-help-need-bulk-disable-account-but-i-need-to-compile-description-field/11445/2 "2018-10-09T15:21:58Z")

</div>

So lets break down that command you found.

**Get-Content D:\script\moveruser.csv |**

Get the users from your csv, although since you’re coming from a csv an import-csv would parse this better for you. If you had a .txt file then Get-Content would be the route you wanted

**Get-ADUser |**

Retrieve the ADUser object for the DN you imported

**Move-ADObject -TargetPath “OU=test2,DC=contoso,dc=org” -PassThru |**

Move the object to the new OU, including the passthru parameter so you get some output to pass onto the disable command.

**Disable-ADAccount**

Disable that account

&nbsp;

You probably want to write this out into more of a script than a one liner. This will give you greater flexibility in what to do with it. I’m writing this on the fly with no testing and not 100% what you mean by your “y.y” statements, but it will hopefully get you moving down the right path.

```
$Users = get-content D:\script\moveruser.txt

ForEach ($user in $users)

{

$userobj = get-aduser $user

$description = "$userobj.description Disabled on "+(get-date).ToShortDateString()

set-aduser $userobj -replace {description="$description"}

disable-adaccount $userobj

Move-ADObject $userobj -TargetPath "OU=test2,DC=contoso,dc=org

}
```

You could also use the import-csv rather than get-content of your csv file. But then you’d need to know what your column header is named to reference the property. But since I don’t know that I’m just assuming your csv is a single column of DNs that can be moved to a txt file.

---

<div class="post-metadata">

**Author:** ![devilsbane](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@devilsbane](https://forums.powershell.org/u/devilsbane)\
**Post date:** [October 10, 2018, 8:49am UTC](https://forums.powershell.org/t/pls-help-need-bulk-disable-account-but-i-need-to-compile-description-field/11445/3 "2018-10-10T08:49:07Z")

</div>

duplicate

---

<div class="post-metadata">

**Author:** ![devilsbane](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@devilsbane](https://forums.powershell.org/u/devilsbane)\
**Post date:** [October 10, 2018, 8:54am UTC](https://forums.powershell.org/t/pls-help-need-bulk-disable-account-but-i-need-to-compile-description-field/11445/4 "2018-10-10T08:54:30Z")

</div>

duplicate, sorry

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:34pm UTC](https://forums.powershell.org/t/pls-help-need-bulk-disable-account-but-i-need-to-compile-description-field/11445/5 "2024-05-16T20:34:15Z")

</div>


