TheJumpCloud / support

Public scripts and examples for managing JumpCloud managed systems and service endpoints
267 stars 152 forks source link

CUT-4021: Add SystemInsights Readable Format for bytes #585

Closed gweinjc closed 3 months ago

gweinjc commented 3 months ago

Issues

What does this solve?

Currently with Get-JCSystemInsights, when returning information from the tables LogicalDrives, Mounts and systemInfo, some of the fields are returned in bytes, which isn't inherently human readable. We want to mimic the functionality of the console and do some calculations to convert the bytes into GB so that it is easier to read.

We are adding the following calculated fields for the Get-JCSystemInsights Tables:

Is there anything particularly tricky?

Windows systems calculate memory and storage with base 2 but display it with a base 10 unit whereas Linux/Mac devices calculate using base 10.

In order to mimic the console, separate calculations need to be completed (LogicalDrives table is used for Windows devices whereas Mount table is used for Linux/Mac)

How should this be tested?

  1. Run the following script to import the module and connect to your org (Replace the USER path and APIKEY):
    Import-Module “/Users/USER/Documents/GitHub/support/PowerShell/JumpCloud Module/JumpCloud.psd1” -force
    Connect-JConline APIKEY -force
  2. systemInfo check:
    • Go into your admin console and select a device, be sure to remember the systemID.
    • Under the Highlights tab, scroll until you see Device Overview
    • Make note of the value for Memory
    • Run the following script and validate that the new PhysicalMemoryGB field matches the Memory value in the Console
      Get-JCSystemInsights -Table SystemInfo -SystemID systemID
  3. Mounts check:
    • Go into your admin console and select a MAC or LINUX device, be sure to remember the systemID.
    • Under the Insights tab, select the System and Hardware tab and scroll to the Mounts section
    • Make note of the value for Storage and Storage Available
    • Run the following script and validate that the new BlocksAvailableGB and BlocksGB fields match the StorageAvailable and Storage values in the Console
      Get-JcSystemInsights -Table Mount -SystemID systemID
  4. logicalDrive check:
    • Go into your admin console and select a Windows device, be sure to remember the systemID.
    • Under the Insights tab, select the System and Hardware tab and scroll to the Logical Drives section
    • Make note of the value for Storage and Storage Available
    • Run the following script and validate that the new FreeSpaceGB and SizeGB fields match the StorageAvailable and Storage values in the Console
      Get-JcSystemInsights -Table logicalDrive -SystemID systemID