Telephone notes - add all groups user is a member off

Welcome Forums General PowerShell Q&A Telephone notes - add all groups user is a member off

This topic contains 1 reply, has 2 voices, and was last updated by

3 years, 10 months ago.

  • Author
  • #21101

    Points: 0
    Rank: Member

    Hello everyone 🙂

    I'm a beginner at powershell. My question what script all oneliner would do this: copy all groups that user is a member off, clear member off and paste in to telephones/notes?

    I know command to replace notes Set-ADUser username -Replace @{info='New info for the notes field'} clearing all groups is not a problem as well. But how to copy groups to info?

  • #21103

    Points: 0
    Rank: Member

    Unless you've a specific reason for requiring a one-liner, you're talking about involving read and write operations in one go, which I'd normally steer clear of in an Active Directory environment.

    In any case, each AD user account has an attribute called MemberOf, which contains details of each group the user is a member of, and is accessible via the Get-ADUser command.

    Something like the following should work.

    Get-ADUser -Identity JoeBloggs -Properties MemberOf | ForEach-Object -Process {Set-ADUser -Identity $_.DistinguishedName -Replace @{info = $_.memberOf}}

    You will probably be able to drop the

    -Identity $_.DistinguishedName

    part , but the AD cmdlets can sometimes be a bit touchy, so i've put it in for completeness.

    Also note that the .MemberOf property features the DistinguishedName of the group

The topic ‘Telephone notes - add all groups user is a member off’ is closed to new replies.