Solved

Updating value for multiple users

Posted on 2014-03-10
7
236 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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 script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

816 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

14 Experts available now in Live!

Get 1:1 Help Now