get members of group and update company field

Welcome Forums General PowerShell Q&A get members of group and update company field

Viewing 2 reply threads
  • Author
    Posts
    • #189106
      Inactive
      Topics: 1
      Replies: 0
      Points: 0
      Rank: Member

      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 attempy

      $users = Get-ADGroupMember -Identity testgroup -Recursive
      where {$_.enabled -eq $true} | `
      Set-ADUser -Identity $users.SamAccountName -Company "test company"
      
      
    • #189121
      Participant
      Topics: 1
      Replies: 1632
      Points: 3,074
      Helping Hand
      Rank: Community Hero

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

      https://social.technet.microsoft.com/Forums/de-DE/9783b18a-9409-468c-92bc-cf41804eb64b/update-company-field-of-group-members?forum=winserverpowershell

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

    • #189205
      Participant
      Topics: 15
      Replies: 13
      Points: 16
      Rank: Member

      Get-ADGroupMember -Identity testgroup | %{Get-Aduser $_ | where {$_.enabled -eq $true} | %{Set-Aduser $_ -Company "Test Co."}

Viewing 2 reply threads
  • You must be logged in to reply to this topic.