Skip to content

fix: skip Point-and-Print relaxation for existing connections - #60

Merged
man612 merged 9 commits into
mainfrom
fix/skip-point-and-print-when-already-connected
Sep 19, 2026
Merged

man612 merged 9 commits into
mainfrom
fix/skip-point-and-print-when-already-connected

Conversation

@man612

@man612 man612 commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Summary

Prevent temporary Point and Print compatibility from lowering driver-installation protection when the requested shared printer is already connected.

Bug reproduced before this fix

With the target UNC already present in printer inventory, the action still:

  • created an emergency restore snapshot
  • lowered RestrictDriverInstallationToAdministrators
  • called Add-Printer
  • restored the registry afterward

That meant security protection was relaxed unnecessarily even though no connection work was required.

Fix

  • validate the UNC as before
  • immediately check printer inventory for the exact target UNC
  • if already connected, return before:
    • RISK confirmation
    • strict registry read
    • restore snapshot creation
    • Point and Print security relaxation
    • Add-Printer / PrintUI
    • rollback logic
  • explain to the user that the printer is already connected and protection was left unchanged

Regression coverage

tests/PointAndPrintSafetySmoke.ps1 now verifies that an already-connected target:

  • preserves the existing Restore pointer
  • prompts only for the UNC, not RISK
  • creates no snapshot
  • performs no registry read/write
  • performs no Add-Printer call
  • performs no rollback call

Existing success, connection failure, no-op Add-Printer, and rollback failure scenarios remain covered.

Local Windows PowerShell 5.1 verification

  • direct AST parse: pass
  • PSScriptAnalyzer 1.25.0: 0 actionable diagnostics
  • PointAndPrintSafetySmoke: pass
  • LegacyNoOpSmoke: pass
  • RepairOutcomeSmoke: pass
  • RepairPostconditionSmoke: pass
  • RestoreOutcomeSmoke: pass
  • RestoreActionContractSmoke: pass
  • ServiceRestoreScopeSmoke: pass
  • SnapshotScopeSmoke: pass
  • RestoreSafetySmoke: pass
  • Validate.ps1: pass

The connection capability is unchanged; unnecessary security relaxation is removed.

@man612
man612 merged commit b9b4a2d into main Sep 19, 2026
1 check passed
@man612
man612 deleted the fix/skip-point-and-print-when-already-connected branch September 19, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant