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

Group memebership test

$
0
0

Hello,

i need to test for a AD User group membership and i was thinking to use this code:

$aduser = Get-ADUser mariusd -Properties memberof


if($aduser.MemberOf -notcontains 'CN=Group Name,OU=Groups,DC=office,DC=intra'){
    
    'is not memeber; i need to add user to the group'
}
else {'is already meember'}

then i asked my self if anyone else didn't need this and found a better way to do it and i found this: http://gallery.technet.microsoft.com/scriptcenter/5adf9ad0-1abf-4557-85cd-657da1cc7df4 which is very complex and i ask my self: am i do it in the wrong way ? or the function that i found is doing more than a simple membership test ?

Thanks,

Marius



Viewing all articles
Browse latest Browse all 21975

Trending Articles



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