cancel
Showing results for 
Search instead for 
Did you mean: 

Report on Systems and its Associated Groups

kmaranionjc
JumpCloud Employee
JumpCloud Employee

This script creates a CSV report of system associations (System Group)

How to use:

1. Install the JumpCloud Powershell Module

2. Save the script below to a Powershell file

  • EX: ~/Report-Systems_Bound_To_Groups.ps1
  • Edit the $csvFilePath variable to your desired path

3. In a PowerShell terminal window run:

  • ~/Report-System_Bound_To_Groups.ps1
  • Follow prompts to enter your API Key & OrgID
# This script will create a csv report list of systems with their associated groups to a CSV file

##### Edit the following variable #####
$csvFilePath = "/Users/kmaranion/systemsWithGroups.csv" # Path to the CSV file. Change this to your own path
##### End Edit #####
$systems = Get-JcSdkSystem

$systems | ForEach-Object {
    $systemGroup = Get-JcSdkSystemMember -SystemId $_.Id
    $listofSystemGroup = @() # list of group associated with the system
    $systemGroup | ForEach-Object {
        Get-JcSdkSystemGroup -id $_.Id | Select-Object -ExpandProperty name | ForEach-Object {
            $listofSystemGroup += $_
        }
    }

    $systemsWithGroups = @()
    $systemsWithGroups += [PSCustomObject]@{
        SystemId       = $_.Id
        SystemHostName = $_.Hostname
        # Convert the list of system groups to a string
        SystemGroups   = $listofSystemGroup -join ','
    }

    # Export the list of systems with its associated groups to a CSV file
    Write-Output "Appending to CSV file the following system: $( $systemsWithGroups | Select-Object -Property SystemId, SystemHostName, SystemGroups)"
    $systemsWithGroups | Export-Csv -Path $csvFilePath -Append
}

Example:

kmaranionjc_0-1682011366561.png

 

 

0 REPLIES 0