Skip to content

improvement(non-interactive): param-or-env input across all scripts; drop RMM variable + prompts#105

Open
Gumbees wants to merge 6 commits into
mainfrom
improvement/drop-rmm-variable
Open

improvement(non-interactive): param-or-env input across all scripts; drop RMM variable + prompts#105
Gumbees wants to merge 6 commits into
mainfrom
improvement/drop-rmm-variable

Conversation

@Gumbees

@Gumbees Gumbees commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Establishes and rolls out a single input standard across the whole script library:

Every input is supplied only as a -Parameter or as an $env: variable of the same name. Each parameter defaults to its $env: counterpart, so either form works. There is no Read-Host, no $env:RMM flag, and no [Environment]::UserInteractive gate — scripts are non-interactive by design and never block waiting for input.

This supersedes the earlier "gate on UserInteractive" approach in the first commit of this PR.

Changes

  • script-template-powershell.ps1 rewritten to the param-or-env pattern.
  • CLAUDE.md updated: input-handling standard, NinjaRMM output writes re-gated on Get-Command Ninja-Property-Set (not an RMM flag), cross-context OrgName, Testing section, and the Git Workflow section (now: main is the single trunk; development retired).
  • ~104 scripts converted: each gains a param() block (one [string] per input, defaulting to $env:<Name>); the if ($RMM)/if (UserInteractive) + Read-Host blocks are removed. Original defaults, required-input validation (now fail-fast, no prompt fallback), log-path logic, and all automation are preserved.

Verification

  • Every changed script parses cleanly as UTF-8 (PowerShell AST parser, 0 syntax errors).
  • Repo-wide sweep confirms no Read-Host / $env:RMM / $RMM / UserInteractive remains as code.
  • Each script transformed by one agent and independently verified (syntax + forbidden-pattern + param-coverage vs original).

Notes

  • ~15 scripts also pick up a CRLF→LF normalization that the repo's .gitattributes (* text=auto) already mandated (their blobs predated the policy), so those diffs look whole-file though the real change is only the input handling.
  • A library-wide refactor will create merge conflicts for other open PRs that modify these same scripts when they rebase onto main.

…serInteractive

The $env:RMM / $RMM flag added noise and was a recurring source of hangs when it
wasn't set/seen. Remove it from today's scripts and the standard; decide interactive
vs unattended solely via [Environment]::UserInteractive.

Scripts (checkpoint-aging, delete-all-checkpoints, suspend-bitlocker,
enable/disable-core-isolation):
- Gate prompts on `if ([Environment]::UserInteractive)`.
- Drop the `## $env:RMM` doc line and the `Write-Host "RMM:"` line.
- $env:Description / $env:DaysAging / $env:RMMScriptPath unchanged.

Standard:
- CLAUDE.md: execution mode is decided by UserInteractive, not an RMM variable.
- script-template-powershell.ps1: template gate + header updated to match.

Supersedes #100 and #104.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Gumbees Gumbees added type:enhancement New work that adds or improves capability (Halo: Enhancement) category:improvement Hardening or polish on existing capability labels Jun 24, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, push a new commit or reopen this pull request to trigger a review.

Gumbees and others added 2 commits June 25, 2026 08:24
Every input is now supplied only as a -Parameter or an $env: variable of
the same name (each param defaults to its $env: counterpart). No Read-Host,
no $env:RMM flag, no [Environment]::UserInteractive: scripts are
non-interactive by design and never block waiting for input.

Rewrites script-template-powershell.ps1 to the new pattern and updates
CLAUDE.md (input-handling standard, NinjaRMM output gating via Get-Command,
cross-context OrgName, Testing section) and the now-current Git Workflow
section (main is the single trunk; development retired).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Applies the script-template-powershell.ps1 standard across the library:
each script gains a param() block (one [string] per input, defaulting to
its $env: counterpart) and the if($RMM)/if([Environment]::UserInteractive)
+ Read-Host input blocks are removed. Original defaults, required-input
validation (now fail-fast, no prompt fallback), log-path logic, and all
automation are preserved. NinjaRMM output writes are re-gated on
Get-Command Ninja-Property-Set instead of an $env:RMM flag.

103 scripts converted. Verified: every changed script parses cleanly as
UTF-8 and no Read-Host / $env:RMM / $RMM / UserInteractive remains as code.

Note: ~15 scripts also pick up a CRLF->LF normalization that the repo's
.gitattributes (* text=auto) already mandated; their blobs predated it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Gumbees Gumbees changed the title improvement(non-interactive): drop the RMM variable, gate purely on UserInteractive improvement(non-interactive): param-or-env input across all scripts; drop RMM variable + prompts Jun 25, 2026
Gumbees and others added 2 commits June 25, 2026 09:19
…g noise

- OrganizationKey now defaults to $env:NINJA_ORGANIZATION_NAME and TagsKey to
  $env:NINJA_LOCATION_NAME (Ninja's built-in org/location variables). AccountKey
  still passes through from its $env: Ninja variable (unchanged).
- Remove the dead $acctkey/$orgkey/$tags command-line override blocks: nothing set
  those under RMM usage and, with Set-StrictMode enabled, they only emitted
  "variable cannot be retrieved" errors into the output log on every run.
- Declare the install-mode switches ($reregister/$reinstall/$uninstall/$repair) at
  script scope (default off = normal fresh install) for the same reason.

Behavior preserved (verified): script parses clean and an unattended run now emits
zero StrictMode undefined-variable errors instead of 4+.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Lightweight RMM condition script (modeled on msft-windows-s2d-health-check):
detects recent bluescreens and exits 1 so an RMM monitor can alert; exits 0
when clean. Unlike msft-windows-bsod-diagnostics, it needs no API key and does
no AI analysis -- it just answers "did this machine bluescreen recently?".

Detection within a configurable window ($LookbackDays / $env:LookbackDays,
default 1):
- Bug Check events (Microsoft-Windows-WER-SystemErrorReporting, Event ID 1001) --
  the authoritative "rebooted from a bugcheck" signal, with stop code + dump path
- Minidump files in %SystemRoot%\Minidump written within the window

Written to the non-interactive param-or-env standard. Verified: parses clean and
runs (exit 0 / no false positives) on a machine with no crash history.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ntion)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:improvement Hardening or polish on existing capability type:enhancement New work that adds or improves capability (Halo: Enhancement)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant