Skip to content

bug(checkpoints): never hang on Read-Host in non-interactive RMM runs#100

Closed
Gumbees wants to merge 1 commit into
mainfrom
bug/checkpoint-scripts-no-interactive-hang
Closed

bug(checkpoints): never hang on Read-Host in non-interactive RMM runs#100
Gumbees wants to merge 1 commit into
mainfrom
bug/checkpoint-scripts-no-interactive-hang

Conversation

@Gumbees

@Gumbees Gumbees commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Problem (observed in production)

Run Windows Hyper-V Checkpoint Aging started under NinjaRMM (Variables: rmm = 1) and hung with no output — never finished.

No output before the hang = it reached Read-Host and is waiting for keyboard input that never arrives in an unattended RMM session. It got there because the RMM-mode gate if ($env:RMM -ne "1") didn't evaluate as RMM mode (the deployed copy isn't seeing the preset as "1").

Fix

Require an interactive session before ever prompting:

if ($env:RMM -ne "1" -and [Environment]::UserInteractive) { ... Read-Host ... }
else { ... RMM mode, safe defaults ... }

NinjaRMM runs scripts non-interactively ([Environment]::UserInteractive is $false), so even if the RMM variable is missing/renamed/not seen, the script now falls through to RMM mode and completes instead of blocking. A genuine interactive run by a tech still prompts. Applied to both checkpoint scripts. No other logic or exit-code changes.

⚠️ Deployment note

Your earlier run did read $env:RMM = 1 and completed, so the copy hanging now is very likely a stale version in the NinjaOne Script Library, not main. After merging, update both scripts in NinjaOne → Scripting → Library from main — otherwise the old hanging copy keeps running.

Testing

  • [Parser]::ParseFile clean on both.
  • Logic: non-interactive + any RMM-var state → RMM branch (no Read-Host).

🤖 Generated with Claude Code

… session

Symptom: the aging script started under NinjaRMM and hung with no output. That
is Read-Host waiting for input that never comes -- reached because the RMM-mode
gate (`if ($env:RMM -ne "1")`) evaluated the run as interactive (e.g. the preset
variable wasn't seen as "1" by the deployed copy).

Harden the gate to also require an interactive session:
`if ($env:RMM -ne "1" -and [Environment]::UserInteractive)`. NinjaRMM runs scripts
non-interactively (UserInteractive = $false), so a missing/renamed RMM variable now
falls through to RMM mode with safe defaults instead of hanging. A real interactive
tech run still prompts.

Applied to both checkpoint scripts. No other logic/exit-code changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Gumbees Gumbees added type:problem Fixing broken or unintended behavior (Halo: Problem) category:bug Buggy behavior that should be corrected 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

Gumbees commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #105, which removes the $env:RMM variable entirely and gates purely on [Environment]::UserInteractive (the final form of this change).

@Gumbees Gumbees closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:bug Buggy behavior that should be corrected type:problem Fixing broken or unintended behavior (Halo: Problem)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant