In AD change attribute for members of a group

I need to modify an AD attribute for all members of an AD group. I can get this to work if the group has only a single member, but any more it fails. So I know I have something wrong. Any help much appreciated.

So used this command to get users of a group:-

$Names = Get-AdGroupMember -identity "TestGroup"

Used this to set their Mobile Phone as testing123,

Set-ADUser $Names -MobilePhone "Testing 123"


Set-ADUser : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADUser' required by parameter 'Identity'. Specified 
method is not supported.
At line:1 char:12
+ Set-ADUser $Names -MobilePhone "Testing 123"
+            ~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.SetADUser


Welcome to the forum. :wave:t3:

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in 1 <---- Click :point_up_2:t4: :wink:

If you carefully (re-)read the help for

You will see that it only takes a single AD user. If you want to change more than one you have to use a loop.

Ok will post correctly next time, apologises for not posting correctly originally.
Have now edited my post. :slight_smile:

Thanks for that link, I couldn’t find what you were referencing though? Not sure what the loop command is or whereabouts in either command it would be used?


You may do a big step back and start with learning the very fundamentals of PowerShell first. This will save you from a lot of wasted time and frustrations. And it will enable you to understand the help you get in forums like this.

   [-Identity] <ADUser>

If you know how to read the help this tells you that you can only provide a single ADUser.

In contrast to that …

   [-PrincipalsAllowedToDelegateToAccount <ADPrincipal[]>]

You could provide one or more ADPrincipal shown by the [] directly after the value name.

Please use your prefered internet search engine to look for examples for tasks like this. It is a very common task and has been asked a lot of times and has been answered a lot of times already.
It is beyond the scope of this or any forum to teach you basic PowerShell.

Thank you for taking the time to give me some good pointers and for assisting me. I have previously tried to get to learn some more of the basics but do struggle with some elements. But of course accept what you are saying. I did some searching for the loop command but couldn’t find anything that really helped in this circumstance.

Are there any particular YouTube videos etc. you would suggest as a good starting point for using Powershell within AD please?

I’d recommend NOT to focus on working with AD in particular. Instead start with learning the common basics.

One fundamental key knowledge is how to read the help. Here you can read more about:

… and you asked for videos … here you go:

Still a good starting point is the video series Getting Started with PowerShell 3.0. Don’t worry that it is about version 3.0. The basics are still the same.

1 Like

One of the best resources for learning to use Powershell with no background in it is Windows PowerShell 4.0: TFM (The F****** Manual) ( it is a free download.

Learning to use PowerShell by applying it to administrative tasks in AD is actually a really good way to apply and develop PowerShell skills. But you need a foundation of knowledge first, Olaf is 100% correct on this. Check out the book, it is exactly what you need to be able to write the scripts you want and need. One of the authors is also in the video series (which is also very good) that Olaf provided a link to.

1 Like

Thank you both for the links, will take a look and read through/watch the videos.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.