none
update company field of group members RRS feed

  • Question

  • this should be simple...but i'm having problems getting it done. I could do this if i exported to a csv and then imported that but i'd like to do this on the "fly" ...plus i'd learn something new!

    basically trying to get members of an ad group and update the company name field of each member, i've tried different ways of looping but cant get it to work.  thanks for the help

    here's my last attempt

          $users = Get-ADGroupMember -Identity testgroup -Recursive 
          where {$_.enabled -eq $true} | `
          Set-ADUser -Identity $users.SamAccountName -Company "test company"


     

     

     

    Tuesday, November 19, 2019 5:27 PM

All replies

  • Is it really necessary to crosspost in more than one forum at the same time without even waiting some minutes for an answer?

    https://powershell.org/forums/topic/get-members-of-group-and-update-company-field/#post-189121

    You could at least post a link to the crossposts to avoid people willing to help you spend some effort for nothing.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, November 19, 2019 5:36 PM
  • You should use a Foreach-Object loop to tread every AD user want to update. Please read the complete help including the examples to learn how to use it.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, November 19, 2019 5:39 PM
  • In this scenario the "Recursive" parameter cannot be used and you must filter for "User" account objects or there will be errors.

    Most of the issues are a lack of basic knowledge of PowerShell syntax which is something that must be learned before trying to use PowerShell.  YOu cannot learn PowerShell by copying code or asking questions in forums.

    Here is a simple tutorial which should be mastered before using PowerShell. It can be learned in a short few hours and will allow you to move forward quickly with PowerShell.

    https://www.tutorialspoint.com/powershell/powershell_quick_guide.htm


    \_(ツ)_/

    Tuesday, November 19, 2019 5:58 PM
    Moderator
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, December 6, 2019 7:23 AM
    Moderator