---
name: reference_rmm_drive_map_explorer_refresh
description: Mapping a drive for a user via RMM user_session works but their running Explorer won't show it until a shell DRIVEADD notify; also UNC \\ gets eaten in heredoc+jq dispatch
metadata:
  type: reference
---

When you map a persistent network drive **for a logged-on user** via the GuruRMM agent's
`context: user_session` (`net use` / `New-SmbMapping -Persistent $true`), two things bite:

1. **The map lands in the user's session but their already-running Explorer won't display it.**
   The drive IS mounted (verify: `user_session` SID == `explorer.exe` SID via
   `Get-CimInstance Win32_Process -Filter "Name='explorer.exe'"`) and `Test-Path X:\` is True,
   but "This PC" doesn't show the icon because the shell never got the add notification.
   **Fix (no disruption, runs in user_session = the user's session 1):**
   ```powershell
   $sig = @'
   [DllImport("shell32.dll", CharSet=CharSet.Unicode)] public static extern void SHChangeNotify(int eventId, uint flags, string item1, string item2);
   '@
   $sh = Add-Type -MemberDefinition $sig -Name ShellNotify -Namespace W -PassThru
   $sh::SHChangeNotify(0x00000100, 0x0005, 'X:' + [char]92, $null)  # SHCNE_DRIVEADD, SHCNF_PATHW
   ```
   The persistent map (`HKCU\Network\X`) auto-reconnects + shows on the user's NEXT logon anyway,
   so this is only to surface it in the current session. Restarting explorer.exe also works but
   closes the user's open windows. An interactive scheduled task (`LogonType Interactive`) to
   "remap in the session" returned `LastTaskResult=2` and did NOT help — use SHChangeNotify.

2. **UNC double-backslashes get mangled to single in the heredoc -> jq -> agent -> PowerShell chain.**
   `\\cs-server\share` arrives as `\cs-server\share` -> "error 67 / network name not found" or net-use
   hangs (looks like a missing/broken share). Single-backslash local paths (`D:\Shares`) are fine.
   **Fix:** build the UNC at runtime from `[char]92` so no literal `\\` traverses the dispatch:
   `$bs=[char]92; $unc = "{0}{0}server{0}share" -f $bs`. See [[feedback_windows_quote_stripping]].

Proven 2026-06-24 on Cascades #32193 (Executive share, E: for Ashley.Jensen + Meredith.Kuhn).
