Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Get groupmembership of a user
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ThorstenK  
View profile  
 More options Jan 8 2008, 8:59 am
Newsgroups: microsoft.public.windows.powershell
From: ThorstenK <Thorst...@discussions.microsoft.com>
Date: Tue, 8 Jan 2008 05:59:01 -0800
Local: Tues, Jan 8 2008 8:59 am
Subject: Get groupmembership of a user
Hello,

i'm trying to write a script that checks several Security Groups if a user
is member of one of those.
But i cant find a way to enumerate the groups a user is a member of or what
users are member of a specific group.

i need somehing like this:
IF <User> is member of <Group> execute command1

final my script should look like this:
$Mailboxes = get-mailbox
foreach ($A in $Mailboxes) {
  IF $A is memberof Group1 execute cmd1
  ELSEIF $A is memberof Group2 execute cmd2
  ELSEIF $A is memberof Group3 execute cmd3
  ELSE execute cmd4

can someone help me please?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shay Levi  
View profile  
 More options Jan 8 2008, 8:59 am
Newsgroups: microsoft.public.windows.powershell
From: Shay Levi <n...@addre.ss>
Date: Tue, 8 Jan 2008 13:59:43 +0000 (UTC)
Local: Tues, Jan 8 2008 8:59 am
Subject: Re: Get groupmembership of a user
For domain users and groups, download Quest's cmdlets for active directory.
It's free, You can download it here:

http://www.quest.com/activeroles-server/arms.aspx

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RichS  
View profile  
 More options Jan 8 2008, 9:34 am
Newsgroups: microsoft.public.windows.powershell
From: RichS <Ri...@discussions.microsoft.com>
Date: Tue, 8 Jan 2008 06:34:02 -0800
Local: Tues, Jan 8 2008 9:34 am
Subject: RE: Get groupmembership of a user
Are all of these groups mutually exclusive ie can a user only be a member of
1 of them??  Do you want to process for all users in a particular group?
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brandon Shell [ MVP ]  
View profile  
 More options Jan 8 2008, 9:32 am
Newsgroups: microsoft.public.windows.powershell
From: Brandon Shell [MVP] <a_bshell.m...@hotmail.com>
Date: Tue, 8 Jan 2008 14:32:05 +0000 (UTC)
Local: Tues, Jan 8 2008 9:32 am
Subject: Re: Get groupmembership of a user
Perhaps this will help (assuming you dont want to install the Quest cmdlets)

found here: http://bsonposh.com/modules/wordpress/?page_id=22

For local Groups
---------------
function Get-GroupMember{
    # From: Brandon Shell (bsonposh.com)
    # Example:
    # -- To List Users of a group
    # PS> Get-GroupMembers -group Administrators -server  myserver1
    # -- To Check if User is member of Group
    # PS> Get-GroupMembers -group Administrators -server myserver -user jsmith
    #################################################################
    Param([string]$group,[string]$server,[string]$user)

    # Check if $server has value. If not set to Local Host Name
    If(!($server)){$server = get-content env:COMPUTERNAME}

    # Getting Group Object
    $g = [ADSI]("WinNT://$server/$group,group")

    # Getting Member User Names
    $ulist = $g.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name",
'GetProperty', $null, $_, $null)}

    # If User is specified we check each member for match
    if($user){
        foreach($u in $ulist){
            if($u -eq $user){$found = $true}
        }
        if($found){Write-Host "User [$user] Found" -ForegroundColor green;$true}
        else{Write-Host "User [$user] NOT found!" -ForegroundColor red;$false}
    }
    else{ # No user specified... Output Member list
        $ulist
    }

}

For Domain Groups
------------------
function Get-ADGroupMember{
    # From: Brandon Shell (bsonposh.com)
    # Example:
    # -- To List Users of a group
    # PS> Get-GroupMembers -group Administrators -server  myserver1
    # -- To Check if User is member of Group
    # PS> Get-GroupMembers -group Administrators -server myserver -user jsmith
    #################################################################
    Param([string]$group,[string]$server,[string]$user)

    # Check if $server has value. If not set to Local Host Name
    If(!($server)){$server = ([ADSI]"").DC}

    # Getting Group Object
    $g = [ADSI]("WinNT://$server/$group,group")

    # Getting Member User Names
    $ulist = $g.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name",
'GetProperty', $null, $_, $null)}

    # If User is specified we check each member for match
    if($user){
        foreach($u in $ulist){
            if($u -eq $user){$found = $true}
        }
        if($found){Write-Host "User [$user] Found" -ForegroundColor green;$true}
        else{Write-Host "User [$user] NOT found!" -ForegroundColor red;$false}
    }
    else{ # No user specified... Output Member list
        $ulist
    }

}

Brandon Shell
---------------
Blog: http://www.bsonposh.com/
PSH Scripts Project:  www.codeplex.com/psobject

T> Hello,
T>
T> i'm trying to write a script that checks several Security Groups if a
T> user
T> is member of one of those.
T> But i cant find a way to enumerate the groups a user is a member of
T> or what
T> users are member of a specific group.
T> i need somehing like this:
T> IF <User> is member of <Group> execute command1
T> final my script should look like this:
T> $Mailboxes = get-mailbox
T> foreach ($A in $Mailboxes) {
T> IF $A is memberof Group1 execute cmd1
T> ELSEIF $A is memberof Group2 execute cmd2
T> ELSEIF $A is memberof Group3 execute cmd3
T> ELSE execute cmd4
T> can someone help me please?
T>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google