Solved

Updating value for multiple users

Posted on 2014-03-10
7
234 Views
Last Modified: 2014-03-11
Hi EE

There is an attribute called " gidNumber" on our AD accounts that is used for Unix access.
I need to update the value for multiple accounts but testing on just one account it does not
find the attribute .

If I do:
Set-ADUser "Test123" -gidNumber "10"

I receive the error below .

Set-ADUser : A parameter cannot be found that matches parameter name 'gidNumber'.
At line:1 char:23
+ Set-ADUser "Test123" -gidNumber "10"
+                       ~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser


When I run the command below it does show me the current gidNumber value .
Get-ADUser "Test123" -Properties * | select gid*
0
Comment
Question by:MilesLogan
  • 4
  • 3
7 Comments
 
LVL 39

Expert Comment

by:footech
ID: 39918501
Just because there is an attribute called "gidNumber" doesn't mean there is a parameter for Set-Aduser with the same name.  When Set-ADUser doesn't include a specific parameter to adjust an attribute, you can use the -add, -replace, -remove, and -clear parameters to modify those attributes based on their LDAP display names.
So you could use
Set-ADUser "Test123" -replace @{gidNumber="10"}

Open in new window

0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39918530
Thanks footech for the explanation ..  I ran below and it worked .

gc users.txt | Set-ADUser -Replace @{gidNumber="1000"}

can you help me output a file of the accounts that where modified ? or I can ask it in another question if needed .
0
 
LVL 39

Expert Comment

by:footech
ID: 39918574
I'm not sure I understand your requirements.
Your users.txt file should already contain a list of the users that are modified.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 2

Author Comment

by:MilesLogan
ID: 39918606
actually .. I just saw something ..

Not all accounts in users.txt will need to have the gidNumber changed to 1000 ..only the accounts that have a number in that field already... if there is no value , then nothing needs to be done .

Can you help me with a script for that ?
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 39919082
Try the following.
gc users.txt | % { Get-ADUser $_ -properties gidNumber } | ? {$_.gidNumber} | Set-ADUser -Replace @{gidNumber="1000"} -PassThru | % { Write-Output "$($_.samaccountname) was updated" } | Out-File updatedusers.txt

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39922092
Hi footech:  this worked ! thanks !
0
 
LVL 39

Expert Comment

by:footech
ID: 39922156
You're welcome.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now