Running CISA ScubaGear with Grok Bot: Setup, Prompts and a Weekly Routine

Underwater photograph of a kelp forest with shafts of sunlight and a school of small silver fish

If you want to measure a Microsoft 365 tenant against a published, government-grade baseline, ScubaGear is the tool. It is free, it comes from CISA, and it produces a report you can act on. It also has one catch that surprises people with an agent in the mix: it only runs on Windows. This post covers how I would deploy and run it with Grok Bot, including a weekly routine. It is a companion to my Maester v3 post.

I checked the official sources on 30 November 2026. The current release is ScubaGear 2.0.0, published on 22 October 2026 on both the GitHub releases page and the PowerShell Gallery.

Why ScubaGear

CISA’s Secure Cloud Business Applications (SCuBA) project publishes secure configuration baselines for Microsoft 365 and Google Workspace. ScubaGear checks a tenant against the Microsoft 365 baselines. CISA says organisations in every sector can use them, not only federal agencies; see the CISA SCuBA page. Under the hood, ScubaGear queries Microsoft 365 APIs, compares the settings with Open Policy Agent (OPA) policies, and writes HTML, JSON and CSV results.

For an MSP, that gives you a repeatable baseline assessment to run for a client, and a clear list of what to fix.

Where it runs, and how Grok Bot fits

Here is the catch. ScubaGear runs on Windows PowerShell 5.1 and Windows only. The ScubaGear dependencies page says some of the Microsoft libraries it uses are tied to PowerShell 5, so it will only run on Windows. The module manifest in the 2.0.0 package I downloaded lists PowerShellVersion 5.1 and the Desktop edition only. That means it does not run on PowerShell 7, and it will not run on Grok Bot’s own Linux computer.

The realistic pattern looks like this:

  • A Windows computer does the assessing. Grok Bot can run commands on a Windows computer you have registered with it. Each of those actions needs your approval in the app. That is fine for setup and for supervised runs, but it is not unattended.
  • Windows Task Scheduler does the unattended run. A scheduled task on that computer runs ScubaGear weekly with a certificate and writes the results into a OneDrive or SharePoint-synced folder. CISA does not document Task Scheduler specifically. This is my own reasonable pattern, built on the “scheduled jobs” non-interactive mode the docs describe.
  • A Grok Bot routine does the thinking. Routines are saved prompts that run on a cron schedule in local time. The routine reads the latest results from OneDrive or SharePoint, compares them with the previous run, and posts a summary to Teams or email through connectors.

If you want a fully hosted option instead, CISA’s own automation is ScubaConnect. Its GearConnect component runs ScubaGear on a schedule in Azure, deployed with Terraform, and keeps configs and results in Azure storage. It is a bigger job than a scheduled task, but it is the official route for multiple tenants.

Prerequisites and the service principal

For interactive runs you sign in as a person. For scheduled runs, ScubaGear supports one method only: a service principal that authenticates with a certificate thumbprint. The certificate must be in the Cert:\CurrentUser\My store of the account running the task. The non-interactive permissions page sets out what each product needs:

Product (ProductNames value)Interactive roleService principal needs
Entra ID (aad)Global ReaderGraph application permissions: Directory.Read.All, Policy.Read.All, PrivilegedAccess.Read.AzureADGroup, PrivilegedEligibilitySchedule.Read.AzureADGroup, RoleManagement.Read.Directory, RoleManagementPolicy.Read.AzureADGroup, User.Read.All
Security Suite (securitysuite)Global Reader or Exchange AdministratorExchange.ManageAsApp, plus the Global Reader role
Exchange Online (exo)Global Reader or Exchange AdministratorExchange.ManageAsApp, plus the Global Reader role
Teams (teams)Global Reader or Teams AdministratorGlobal Reader role
SharePoint and OneDrive (sharepoint)Global Reader or SharePoint AdministratorSites.FullControl.All
Power Platform (powerplatform)Power Platform Administrator with a Power Apps for Office 365 licenceOne-time registration of the app with New-PowerAppManagementApp
Power BI (powerbi)Fabric Administrator or Global Administrator, with a Power BI or Fabric licenceA Power BI admin tenant setting, applied through a security group, and no API permission

Be honest with yourself about the last three rows. The docs say the SharePoint and Power Platform permissions include write privileges, because the underlying APIs require them, and that ScubaGear itself never uses them for its assessments. I would start with aad, securitysuite, exo and teams, which only need read access, and add the others deliberately.

ScubaGear also includes helpers for the app: New-ScubaGearServicePrincipal creates the app, permissions and certificate, Get-ScubaGearAppPermission and Set-ScubaGearAppPermission audit and fix permissions, and Get-ScubaGearAppCert, New-ScubaGearAppCert and Remove-ScubaGearAppCert handle certificate rotation. The service principal workflows guide covers them. An admin should run these, not the bot. The certificate defaults to six months, so plan for rotation.

Setup, with prompts to give Grok Bot

1. Install ScubaGear

Use my registered Windows computer. Check that Windows PowerShell 5.1 is available, not PowerShell 7. Then run Install-Module -Name ScubaGear and tell me the output of Invoke-SCuBA -Version. I will approve each action.

2. Install the dependencies

Run Install-ScubaDependencies on the Windows computer. Tell me what it installed, and confirm that OPA and the MSAL files exist in the .scubagear folder in my home directory.

Initialize-SCuBA still works as an alias for Install-ScubaDependencies. The dependencies are the powershell-yaml module, OPA and the Microsoft Authentication Library assemblies.

3. Generate the YAML configuration

In C:\Scuba, run New-SCuBAConfig -Organization contoso.onmicrosoft.com -ProductNames “aad,securitysuite,exo,teams”. Read the generated SampleConfig.yaml and list what I need to fill in. Don’t guess any values. Ask me for the object IDs of our emergency access accounts.

ScubaGear works best with a config file. Without one it assumes defaults that may not reflect your policies, as the README explains. The configuration guide covers every option, and Start-SCuBAConfigApp opens a graphical editor on Windows, but that is one for you at the keyboard.

4. First interactive run

Tell me when you are ready, so I can be at the Windows computer for the browser sign-in. Then run Invoke-SCuBA -ProductNames aad,securitysuite,exo,teams -ConfigFilePath C:\Scuba\SampleConfig.yaml -OutPath C:\Scuba\Results -SilenceBODWarnings. Afterwards, run Get-ScubaGearContext and confirm which tenant was used.

5. Move to the certificate

Walk me through creating the ScubaGear service principal with New-ScubaGearServicePrincipal -M365Environment commercial -ProductNames ‘aad’,’securitysuite’,’exo’,’teams’ -ServicePrincipalName ‘ScubaGear-Production’. Run it with -WhatIf first and explain the output. I will do the admin sign-in. Then run Get-ScubaGearAppPermission to verify, and test one run with -AppID, -CertificateThumbprint and -Organization.

Invoke-SCuBA -ProductNames aad,securitysuite,exo,teams `
  -AppID <application-client-id> `
  -CertificateThumbprint <certificate-thumbprint> `
  -Organization contoso.onmicrosoft.com `
  -OutPath C:\Scuba\Results -Quiet

Notice there is no secret to hand over here. The private key stays in the Windows certificate store, and the app ID, thumbprint and organisation are identifiers. If anything else does need a secret, such as a webhook, ask the bot for a masked secret request and never paste it into chat.

6. Triage the first report

Read ScubaResults.json and ActionPlan.csv from the latest Results folder. List the failing SHALL controls first, grouped by product. For each, give the control ID, what failed, the risk in plain English and the fix. Don’t change anything.

Operating it

  • Explain a failure: “Explain why MS.AAD.1.1v1 failed in our report and what it protects against.”
  • Remediation steps: “Draft step-by-step remediation for the top five failures as a change request for me to review.”
  • Compare runs: “Compare the two most recent ScubaResults files. What newly failed, what was fixed and what is new?” The tool itself has Invoke-SCuBADiff -BeforePath -AfterPath, which works offline and produces DiffResults.json, DiffResults.csv and DiffReport.html.
  • Record a decision: “Add an AnnotatePolicy entry for MS.EXO.3.1v1 with a Comment and a RemediationDate, then show me the diff of the YAML before saving.”
  • Omit or exclude: “Add an OmitPolicy entry with a Rationale and Expiration, or a CapExclusions entry for our emergency access group.” Only record exclusions and omissions that your risk process has approved, because they create blind spots.

Annotations take Comment, RemediationDate and IncorrectResult. Omissions take Rationale and Expiration. Keep the config in version control and have a human approve every change to it.

Running it every week

Step one is the unattended run on the Windows computer. Create a script, C:\Scuba\Run-Scuba.ps1. Put the organisation, app ID and thumbprint in your config file, with Organization, AppID and CertificateThumbprint as the keys, and protect that file:

Import-Module ScubaGear
Invoke-SCuBA -ConfigFilePath C:\Scuba\scuba-config.yaml `
  -OutPath "$env:USERPROFILE\OneDrive\Scuba\Results" -Quiet -SilenceBODWarnings

Then register a weekly task, here Monday at 5am, running as the user whose certificate store holds the certificate:

$action  = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -ExecutionPolicy Bypass -File C:\Scuba\Run-Scuba.ps1'
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday -At 5:00am
Register-ScheduledTask -TaskName 'ScubaGear weekly' -Action $action -Trigger $trigger

The computer needs to be on and the task needs a test run before you trust it. Each run creates a new time-stamped folder under the output path, so history builds up by itself. Step two is the Grok Bot routine, set to run at 7am on Mondays in local time:

Every Monday at 7am Sydney time: look in the OneDrive folder Scuba\Results and find the two newest run folders. If the newest one is older than 24 hours, tell me the scheduled run may have failed and stop. Otherwise read both ScubaResults JSON files and the newest ActionPlan.csv, compare them, and summarise what newly failed, what was fixed and the current counts of passes and failures per product. Post the summary to the Security channel in Teams, or email secops@contoso.com if Teams is unavailable. Don’t change anything anywhere.

This keeps the supervised and unattended parts honest. The Windows task runs without you. The routine reads files and reports, and needs no approval on your computer. Anything that needs the Windows computer, such as checking certificate expiry with Get-ScubaGearAppCert, still asks you to approve it.

Troubleshooting

  • Module will not install or load: check you are in Windows PowerShell 5.1, not PowerShell 7.
  • OPA or MSAL missing: run Install-OPAforSCuBA or Install-MsalForScuBA.
  • Non-interactive sign-in fails: check AppID, CertificateThumbprint and Organization are all supplied, the certificate is in Cert:\CurrentUser\My for the task’s user, and run Get-ScubaGearAppPermission.
  • Wrong tenant: run Get-ScubaGearContext, and Disconnect-SCuBATenant before switching tenants.
  • Power Platform or Power BI errors: these need licences, a one-time registration or a tenant setting. See the product pages in the troubleshooting docs.
  • Old product names: defender is no longer a product name. Use securitysuite, and see the Defender to Security Suite transition guide.

ScubaGear or Maester?

I use both for different reasons. ScubaGear gives you the CISA baselines, with a formal exclusion and annotation model, but it only runs on Windows PowerShell 5.1. Maester runs on PowerShell 7.4 or later, including on Grok Bot’s own computer, so it is simpler to run unattended. They overlap but are not the same set of checks.

Wrap-up

ScubaGear is a strong baseline tool with a Windows requirement that shapes the whole design. Let a Windows computer and a scheduled task do the assessing, and let Grok Bot do the reading, comparing and reporting. Start with four read-only products and a human-approved config, and widen it when you trust the output.

Sources (checked 30 November 2026)

Leave a Reply