Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Need to extract all users from an AD group and then pass off their UserPrincipalName to another cmdlet

$
0
0

Say I have an AD group called "group1" and I'd like to get all members and then pass off their UserPrincipalName (samaccountname + domain name) to another cmdlet, what would be the best method for that? I'm working with a cmdlet that will accept a single UserPrincipalName or an array, so right now I have this:

$group4 = Get-ADGroupMember SAMPLE-GROUP
    foreach ($user in $group4){
    $getuser = get-aduser $User
    $user = $getuser.userprincipalname
    add-tpuser $group4 -Verbose
    }

There's got to be an easier way, though.

Thanks.


zarberg@gmail.com


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>