0
votes

I have about 400 users in one OU. About 100 of these users have the Description field blank. The field Decription should now be filled with the value for the respective one in the attribute EA6. I want to use powershell for this. Can someone support here? Thanks in advance. Herman

These could be the first step. now the srcipt should get the EA1 to variable of all Users in $name and write this to the description of them.

$OUpath = 'OU=XX,OU=XXXX,OU=XXXXXXX,OU=Users,OU=XX,DC=XXX,DC=XXXXXXXXX,DC=XX' $name = Get-AdUser -Filter {(Enabled -eq "True" ) -and (description -notlike '*')} -searchbase $OUpath -Properties Description | Select-Object -ExpandProperty SamAccountName

1
Welcome to SO. Did you take the Tour and did you read the help How to Ask? What kind of support do you need? Did you try to search for a solution? I'm sure there are hundrets of examples of how to acommplish such a task - even / especially here on SO.Olaf
You can limit the search for Get-ADUser by providing the -SearchBase parameter.Olaf
Being new to SO you may not know this, but is customary to accept the answer that solved your problem by clicking ✓ on the left. This will help others with a similar question finding it more easily and helps as motivation for people to answer your questions.Theo

1 Answers

0
votes

To get the extensionAttribute6 value from the user, you need to ask for it in the -Properties parameter for Get-ADUSer, just like the Description property, because both are not returned by default.

Then, you can do something like this:

$ou     = 'OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM'  # enter the distinguishedName of the OU here
$filter = "Enabled -eq $true -and Description -notlike '*'"

Get-AdUser -Filter $filter -SearchBase $ou -Properties Description, extensionAttribute6 | 
    ForEach-Object {
        $_ | Set-ADUser -Description $_.extensionAttribute6
    }