Solved

Updating value for multiple users

Posted on 2014-03-10
7
232 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
Comment Utility
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
Comment Utility
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
Comment Utility
I'm not sure I understand your requirements.
Your users.txt file should already contain a list of the users that are modified.
0
Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

 
LVL 2

Author Comment

by:MilesLogan
Comment Utility
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
Comment Utility
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
Comment Utility
Hi footech:  this worked ! thanks !
0
 
LVL 39

Expert Comment

by:footech
Comment Utility
You're welcome.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
AD FSMO Issues 14 61
Encryption of server 7 62
ACTIVE DIRECTORY 4 23
Powershell script 3 33
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
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…

763 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

7 Experts available now in Live!

Get 1:1 Help Now