Automation

 View Only
  • 1.  Script to display members of groups

    Posted Nov 18, 2015 04:27 PM

    Hi There,

    Want to know if there is a script to display all group members of a all group of a vcenter. spent all my day finding a way with no result.

    already tried this one from Lucd but no member are displayed...  My vcenter and powercli are 5.1

    Get-VIPermission |
    Select
    @{N="VIObject";E={$_.Entity.Name}},
    Role,
    Principal,
    @{N="Members";E={
     
    if($_.IsGroup){
       
    $group = Get-QADGroup $_.Principal
        $names = $group.AllMembers | %{Get-QADObject $_ | Select -ExpandProperty Name}
        [
    string]::Join(',',$names)
      }}}
    |
    export-csv C:\processes.csv -UseCulture -NoTypeInformation

    Anyone can help ?

    Thx



  • 2.  RE: Script to display members of groups

    Posted Nov 19, 2015 08:48 AM

    Do you have the Quest Powershell for Active Directory module installed ?



  • 3.  RE: Script to display members of groups

    Posted Nov 19, 2015 10:11 AM

    Yes already installed.

    No members output...



  • 4.  RE: Script to display members of groups

    Posted Nov 19, 2015 10:38 AM

    i am asking myself.

    I am admin of my vcenter but the Ad is about another team.

    To execute QADcmlet does Admin right for the AD are mandatory ?



  • 5.  RE: Script to display members of groups

    Posted Nov 19, 2015 11:44 AM

    Do you have the Get-AdUser cmdlet ?



  • 6.  RE: Script to display members of groups

    Posted Nov 19, 2015 11:55 AM

    If yes, try like this

    Get-VIPermission |

    Select @{N="VIObject";E={$_.Entity.Name}},

    Role,

    Principal,

    @{N="Members";E={

      if($_.IsGroup){

        $group = Get-ADGroup $_.Principal.Split('\')[1] -Properties Members

        $names = $group.Members | %{Get-ADObject $_ | Select -ExpandProperty Name}

        [string]::Join(',',$names)

      }}} |

    export-csv C:\processes.csv -UseCulture -NoTypeInformation



  • 7.  RE: Script to display members of groups

    Posted Nov 19, 2015 12:42 PM

    Hi,

    Thanks for replies,

    I have the get-aduser, but stlll the same output with the new script

    Vi object role and principal  column are ok but still no members for the last...



  • 8.  RE: Script to display members of groups

    Posted Nov 19, 2015 01:01 PM

    Just to make sure, your Principals are AD groups, not users



  • 9.  RE: Script to display members of groups

    Posted Nov 19, 2015 01:15 PM

    Yes principal column are Ad group.

    Members is empty

    is there another way to extrac members with powercli ?



  • 10.  RE: Script to display members of groups

    Posted Nov 19, 2015 01:23 PM

    How do the principals look like ? domain<username ?

    You will have to use an AD cmdlet to get the info from AD, no PowerCLI cmdlets for that afaik.



  • 11.  RE: Script to display members of groups

    Posted Nov 19, 2015 02:26 PM

    principals looks like domaine\groups.

    Ok thanks for your help



  • 12.  RE: Script to display members of groups

    Posted Nov 19, 2015 06:40 PM

    Can you check if for a Principal like domain\groupname, the following returns the object ?

    Get-ADGroup groupname