Skip to content

[pkg firewall] port the VS Code lifecycle and watcher to PowerShell - #30

Open
dekkagaijin wants to merge 1 commit into
vscode-fw-6-powershell-jsonfrom
vscode-fw-7-powershell-lifecycle
Open

[pkg firewall] port the VS Code lifecycle and watcher to PowerShell#30
dekkagaijin wants to merge 1 commit into
vscode-fw-6-powershell-jsonfrom
vscode-fw-7-powershell-lifecycle

Conversation

@dekkagaijin

Copy link
Copy Markdown
Contributor

Merge after #29

Completes the lib-level port. Mirrors bash/lib/common.sh's vscode_* functions and its watcher, so review is a diff against something already merged.

Get-VSCodeInstallPath / Get-VSCodeEditionLabel / Get-VSCodeInstallRoot
Get-VSCodeNodeBin / Test-VSCodeCanWrite
Get-VSCodeStateDir / Set-VSCodeState / Get-VSCodeState / Write-VSCodeStateReport
Get-VSCodeMarkerField / Get-VSCodeManagedState / Get-VSCodeMarkerBase
Invoke-VSCodePatch / Invoke-VSCodeUnpatch
Invoke-VSCodePatchViaNode / Invoke-VSCodeUnpatchViaNode
Install-VSCodeWatcher / Uninstall-VSCodeWatcher

Three Windows-specific differences from the bash version, each load-bearing:

  • Per-user install discovery uses $UserHome from console-user detection, NOT $env:LOCALAPPDATA. Intune runs scripts as SYSTEM, whose LOCALAPPDATA is under C:\Windows, so relying on the env var would silently miss every per-user install on the fleet.
  • Set-FileRestrictedAcl resolves SYSTEM from the well-known SID S-1-5-18 rather than the name 'SYSTEM', which is localised.
  • Task Scheduler has no file-watch trigger, so the watcher is -AtStartup + -AtLogOn + hourly repetition. -AtLogOn is the proxy for "updated, then relaunched" that launchd's WatchPaths gives for free on macOS.

Absent the Scheduled Task cmdlets, Install-VSCodeWatcher warns and returns false rather than throwing: the patch is still worth applying on a box where the watcher cannot be installed, it just needs re-pushing on each check-in.

Tests: 54 assertions mirroring the bash lifecycle and watcher suites, plus 2 explicit skips. The skips are the point — Scheduled Task registration and %ProgramFiles% / AppData discovery cannot run off-Windows, and a suite that reported green on a Mac while never touching the Windows code path would be worse than no suite. They still need a Windows box before this goes to a Windows fleet.

https://endorlabs.atlassian.net/browse/LM-452

Completes the lib-level port. Mirrors bash/lib/common.sh's vscode_* functions and
its watcher, so review is a diff against something already merged.

  Get-VSCodeInstallPath / Get-VSCodeEditionLabel / Get-VSCodeInstallRoot
  Get-VSCodeNodeBin / Test-VSCodeCanWrite
  Get-VSCodeStateDir / Set-VSCodeState / Get-VSCodeState / Write-VSCodeStateReport
  Get-VSCodeMarkerField / Get-VSCodeManagedState / Get-VSCodeMarkerBase
  Invoke-VSCodePatch / Invoke-VSCodeUnpatch
  Invoke-VSCodePatchViaNode / Invoke-VSCodeUnpatchViaNode
  Install-VSCodeWatcher / Uninstall-VSCodeWatcher

Three Windows-specific differences from the bash version, each load-bearing:

  - Per-user install discovery uses $UserHome from console-user detection, NOT
    $env:LOCALAPPDATA. Intune runs scripts as SYSTEM, whose LOCALAPPDATA is under
    C:\Windows, so relying on the env var would silently miss every per-user
    install on the fleet.
  - Set-FileRestrictedAcl resolves SYSTEM from the well-known SID S-1-5-18 rather
    than the name 'SYSTEM', which is localised.
  - Task Scheduler has no file-watch trigger, so the watcher is -AtStartup +
    -AtLogOn + hourly repetition. -AtLogOn is the proxy for "updated, then
    relaunched" that launchd's WatchPaths gives for free on macOS.

Absent the Scheduled Task cmdlets, Install-VSCodeWatcher warns and returns false
rather than throwing: the patch is still worth applying on a box where the watcher
cannot be installed, it just needs re-pushing on each check-in.

Tests: 54 assertions mirroring the bash lifecycle and watcher suites, plus 2
explicit skips. The skips are the point — Scheduled Task registration and
%ProgramFiles% / AppData discovery cannot run off-Windows, and a suite that
reported green on a Mac while never touching the Windows code path would be worse
than no suite. They still need a Windows box before this goes to a Windows fleet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dekkagaijin
dekkagaijin force-pushed the vscode-fw-7-powershell-lifecycle branch from ab1ddff to ac1a99f Compare August 6, 2026 16:10
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