cancel
Showing results for 
Search instead for 
Did you mean: 

Experimenting with the JumpCloud PowerShell Module in combination with the PowerShellAI Module

JuergenKlaassen
Rising Star III
Rising Star III

Hello Community Folks

While AI, OpenAI, ChatGPT, Bard, AutoGPT and what not is all the rage this year and it's hard to keep up with things, make the right and conscious decisions about LLM's and it's use (or the opposite), I can find my little time slots where I really just want to play around with it. 

Previously I did some early stage testing with GPT-3 and OSquery, which was ok, but also not groundbreaking, no yet. Some weeks ago I stumbled across Doug Finke's pretty amazing PowerShell Module: PowerShellAI
It provides several functions including "AI" which I'm using in combination with JC's PS Module.

 

<#
        .SYNOPSIS
        This is **Experimental** AI function
        .DESCRIPTION
        AI function that you can pipe all sorts of things into and get back a completion
        .EXAMPLE
        ai "list of planets only names as json" |
        .EXAMPLE
        ai "list of planets only names as json" | ai 'convert to  xml'
        .EXAMPLE
        ai "list of planets only names as json" | ai 'convert to  xml' | ai 'convert to  powershell'
        .EXAMPLE
        git status | ai "create a detailed git message"
    #>

 

So, how to combine this with the JS PS Module? 

I've created a few examples for you, but before writing them down here, a few considerations: 

1. Accuracy: it can be fuzzy or simply wrong. The more detailed and instructive your query the better it's output. Verify the results and over time the confidence will likely grow.
2. Data Privacy and sensitivity: Please read OpenAI's policies and then decide by yourself what you're feeding into it.
3. Max Tokens: I increased mine to the max here to be able to ingest bigger payloads

SCR-20230501-nxgr.png

 

Ok, let's show some examples of what's possible after playing around for an hour-ish. 
You will need: 

  1. JumpCloud PowerShell Module
  2. PowerShellAI Module
  3. JumpCloud API Key
  4. OpenAI API Key
  5. your tweaks to the session options, i.e.: max_tokens

1. question: "Which SystemID has the oldest version of Microsoft Edge?

Input: 

 

Get-JcSystemApp -SystemOS "Windows" -Name "Microsoft Edge" | ai "Which SystemID has the oldest version of Microsoft Edge?"

 

Output: 

 

The SystemID with the oldest version of Microsoft Edge is 643756e71850b1ad089de72a.

 

 

2. question: "List the count of each version in alphapetical order"
Input: 

 

Get-JcSystemApp -SystemOS "Windows" -Name "Microsoft Edge" | ai "List the count of each version in alphapetical order"

 

Output: 

 

Count of Version 111.0.1661.41: 1
Count of Version 111.0.1661.54: 1
Count of Version 112.0.1722.48: 1
Count of Version 112.0.1722.64: 2

 


3. question:  
"Which users are suspended?"
Input: 

 

Get-JCUser | ai "Which users are suspended?"

 

Output: 

 

No users are suspended.

 


4. question: Sort all users in the following order: Firstname, Location, Department. Then present as JSON.

Input: 

 

Get-JCUser | ai "Sort all users in the following order: Firstname, Location, Department. Then present as JSON"

 

 Output:

 

[
  {
    "firstname": "Jürgen",
    "location": "",
    "department": ""
  },
  {
    "firstname": "J",
    "location": "",
    "department": ""
  },
  {
    "firstname": "N**a",
    "location": "",
    "department": ""
  },
  {
    "firstname": "Joel",
    "location": "",
    "department": "Marketing"
  },
  {
    "firstname": "John",
    "location": "",
    "department": "Marketing"
  }
]

 


5. question: Explain the script within a Command

Input: 

 

$command = Get-JCCommand -ByID 6305fb151a02ff0fbd7bc527
$command.command | ai "Explain the script. Bullets points please."

 

Output: 

 

• Resolve-Path is used to find the path of the WindowsApps folder
• $WingetPath is set to the path of the WindowsApps folder
• Set-Location is used to change the current directory to the WindowsApps folder
• .\winget.exe is used to install Chrome and Slack from the WindowsApps folder
• The --silent, --accept-package-agreements, --accept-source-agreements, and --scope machine flags are used to install the applications silently and with the correct permissions

 

 


6. question: "Provide statistical insights about the Windows Security Center"

Input: 

 

Get-JcSdkSystemInsightWindowsSecurityCenter | AI "Provide statistical insights about the Windows Security Center"

 

Output: 

 

Statistical Insights:

- The Windows Security Center is performing well, with all components (Antispyware, Antivirus, Autoupdate, Firewall, InternetSettings, and WindowsSecurityCenterService) rated as "Good".

- The UserAccountControl component is the only one rated as "Poor".

- The CollectionTime for the Windows Security Center is spread out over the next few months, with the earliest CollectionTime being 2023-01-03T02:05:41.180Z and the latest CollectionTime being 2023-04-13T02:37:04.796Z.

 


7. question: 
Which are the top 5 [Chrome] extensions found in this dataset? Include version numbers in your response.
Input: 

 

Get-JcSdkSystemInsightChromeExtension | AI "Which are the top 5 extensions found in this dataset? Include version numbers in your response."

 

Output: 

 

Top 5 extensions found in this dataset:
1. Google Docs Offline (Version 1.58.4)
2. Application Launcher For Drive (by Google) (Version 3.5)
3. JumpCloud Password Manager (Version 1.0.15)
4. Chrome Web Store Payments (Version 1.0.0.6)
5. Edge relevant text changes (Version 1.1.1)

 


8. question:  "Explain the policy and each individual setting."
Input: 

 

$policy = Get-JCPolicy -ByID 63c77848619b7600015bf2fe
$policy.values | ConvertTo-Json | ai "Explain the policy and each individual setting."

 

Output: 

 

This policy is for configuring the Zoom Meetings application on Windows machines. Each individual setting is a registry key that will be set in the Windows registry. The settings are as follows:

AutoStartAfterReboot: This setting determines whether or not Zoom will automatically start after a reboot.

AutoStartInSystemTray: This setting determines whether or not Zoom will start in the system tray.

BlockUntrustedSSLCert: This setting determines whether or not Zoom will block untrusted SSL certificates.

Disable3rdModuleVerify: This setting determines whether or not Zoom will verify third-party modules.

DisableCreatingDesktopShortcut: This setting determines whether or not Zoom will create a desktop shortcut.

DisableFacebookLogin: This setting determines whether or not Zoom will allow users to log in with their Facebook account.

DisableGoogleLogin: This setting determines whether or not Zoom will allow users to log in with their Google account.

DisableLoginWithEmail: This setting determines whether or not Zoom will allow users to log in with their email address.

DisableLoginWithSSO: This setting determines whether or not Zoom will allow users to log in with single sign-on (SSO).

 


9. question: "Create insights about this data set" (Batteries)
Input: 

 

$battery = Get-JcSdkSystemInsightBattery
$battery | ai "Create insights about this data set"

 

Output:

 

This data set provides information about two different batteries. The first battery has an amperage of -334, a current capacity of 100, a cycle count of 114, a designed capacity of 4382, a health of "Check Battery", a max capacity of 100, a minutes until empty of 708, a model of bq20z451, a percent remaining of 100, a serial number of F5D04855W5PPJYVA7, a state of "Battery Power", and a voltage of 12753. The second battery has an amperage of -1219, a current capacity of 3800, a cycle count of 63, a designed capacity of 4381, a health of "Good", a max capacity of 3913, a minutes until empty of 209, a model of bq20z451, a percent remaining of 100, a serial number of D860161A0FQN4F1AY, a state of "Battery Power", and a voltage of 12403.

From this data set, we can infer that the first battery is in need of maintenance, as its health is listed as "Check Battery". The second battery is in good condition, as its health is listed as "Good".

 


As you can see, the options and the potential are huge. For sure, some of my first queries produced quite a bit of rubbish sometimes, but you're getting a feeling for it and you iterate along the way. 
It's still a playground for experimentation only as of now. 

Cheers 
Juergen

1 REPLY 1

stefanny
Novitiate I

Hey Juergen,

Great to see someone diving into the fusion of PowerShell and AI. Your examples are very convincing, and wow, it's great that you are pushing the boundaries with JumpCloud PowerShell Module and PowerShellAI.

Combining these tools opens up a myriad of possibilities, but as you rightly pointed out, accuracy can be a bit of a wildcard. It's a game of crafting precise queries, verifying results, and refining over time.

I'd suggest considering a feedback loop to enhance the AI's performance. If results are a bit fuzzy, share your corrections. These models thrive on data and learning from user interactions.

Your points about data privacy are very relevant (what could be more important than security right now?). Always watch what you enter into these systems, especially when dealing with sensitive information.

So, peep these cool examples you've dropped, like sorting out users or pulling insights from Windows Security Center. It really shows the mad power of this combo. Keep hustlin', experimenting, and dropping knowledge bombs with the crew. It's through linking' up and swapping stories that we really unbox the true potential of these tools.

You Might Like

New to the site? Take a look at these additional resources:

Community created scripts:

Our new Radical Admin blog:

Keep up with Product News:

Read our community guidelines

Ready to join us? You can register here.