If your organization has a high number of inactive devices in JumpCloud, you can use the JumpCloud PowerShell Module to execute a clean up script and remove all inactive devices.
The following steps require the JumpCloud PowerShell Module installed on your device. To download and install the JumpCloud PowerShell Module, see Install the JumpCloud PowerShell Module.
Connecting to Your Organization via PowerShell
Before running any commands, you'll first need to connect to the JumpCloud PowerShell Module.
- Open Windows PowerShell on your device and execute the following command:
Connect-JCOnline
- Enter the API key of your JumpCloud account. To gather your API key, see Accessing Your API Key.
- Once you enter the API key, the JumpCloud modules will be imported to the system. Your JCOrgID and JCOrgName are shown after successful import.
- Execute the following command to list all the devices in your JumpCloud org:
Get-JCSystem
Removing Inactive Devices from Your Organization
This command will permanently remove the devices that fall within the criteria. There is no recovery or undo script. Proceed with caution.
- The following command will permanently remove all the devices that have a lastContact date greater than 60 days.
Get-JCSystem | Where-Object lastContact -lT (Get-Date).AddDays(-60).ToString('yyy-MM-ddTHH:MM:ss') | Remove-JCSystem
You can modify the number of days since last contact according to your requirements (for example 30, 60, 90, 120, etc). To do so, modify the value within the AddDays(-XX) field.
- PowerShell prompts for confirmation to remove the selected devices. Select Y (yes) to remove the devices.
After the successful execution of the command, a list of removed devices is displayed. - You can verify the removed devices are no longer visible in the Devices list within your JumpCloud Organization via the Admin Portal.
- Log into your JumpCloud Admin Portal.
- Go to DEVICE MANAGEMENT > Devices and click the Devices tab.
- Cross-reference the Devices list with the output of removed devices from the PowerShell command.