cancel
Showing results for 
Search instead for 
Did you mean: 

Report on Users and its Associated Groups and Systems

kmaranionjc
JumpCloud Employee
JumpCloud Employee

This script creates a CSV report of user associations (Group and Systems) 

How to use:

1. Install the JumpCloud Powershell Module

2. Save the contents of the script example to a file on a system.

  • EX: ~/Report-Users_Bound_To_Groups.ps1

3. In a PowerShell terminal window run:

  • ~/Report-Users_Bound_To_Groups.ps1
  • Follow prompts to enter your API Key & OrgID

Script

 

# Get everyone from a group
$users = Get-JcSdkUser
# Initialize an empty list
$list = @()
# For each user
foreach ($user in $users)
{
    $userDetails = Get-jcsdkUser -Id $user.id
    # Get System Associations
    $systemAssociations = Get-JcSdkUserTraverseSystem -UserId $user.Id
    # Get Group Associations
    $groupAssociations = Get-JcSdkUserMember -UserId $user.Id
    # Clear variables
    $foundSystem = ""
    $foundGroup = ""
    # For each system association
    foreach ($systemAssociation in $systemAssociations)
    {
        $foundSystem += $systemAssociation.Id + ';'
    }
    # For each group association
    foreach ($groupAssociation in $groupAssociations)
    {
        $foundGroup += $groupAssociation.Id + ';'
    }
    # populate the rows
    $list += [PSCustomObject]@{
        userID            = $user.Id;
        username          = $userDetails.Username;
        userState         = $userDetails.State
        associatedSystems = $foundSystem
        associatedGroups  = $foundGroup
    }
}
# Write out the report
$list | ConvertTo-Csv | Out-File Report-UserToGroupAssociation.csv

 

0 REPLIES 0