The error comes from how you tried to build the registry path string — the backslash is a special character and your -replace expression/Join-Path call produced a null or invalid Path. The simplest fixes are either (A) avoid trying to -replace backslashes at all and interpolate $inst directly into a string, or (B) split the InstanceId on backslashes and re-join safely. Either way also check that $inst is not null.
Use one of these corrected approaches (run PowerShell as Administrator).
Option A — simplest (interpolate the InstanceId directly)
This works if $inst contains something like FTDIBUS\VID_0403+PID_6001+ABC123\0000
$inst = 'FTDIBUS\VID_0403+PID_6001+ABC123\0000' # replace with real InstanceId
$dp = "HKLM:\SYSTEM\CurrentControlSet\Enum\$inst\Device Parameters"
Write-Output "Device Parameters path = $dp"
verify then read
if (Test-Path $dp) { Get-ItemProperty -Path $dp | Format-List } else { Write-Warning "$dp not found" }
Option B — robust (split and Join-Path)
This avoids fiddling with -replace regex escaping:
$inst = 'FTDIBUS\VID_0403+PID_6001+ABC123\0000' # replace with real InstanceId
$enumBase = 'HKLM:\SYSTEM\CurrentControlSet\Enum'
$parts = $inst -split '\' # splits on literal backslash
$subPath = $parts -join '\' # re-join with backslashes
$regPath = Join-Path $enumBase $subPath
$dp = Join-Path $regPath 'Device Parameters'
Write-Output "Device Parameters path = $dp"
if (Test-Path $dp) { Get-ItemProperty -Path $dp | Format-List } else { Get-ChildItem -Path $regPath -Recurse -Depth 2 | Format-List PSPath }
Full safe script to detect & write (handles null, logs, and avoids the previous error)
Run this elevated (Admin). It will find FTDI COM ports, build the correct Device Parameters path, show current values and try to write the four common selective‑suspend properties.
Run as Administrator
$log = "$env:USERPROFILE\Desktop\FTDI_write
log$(Get-Date -Format yyyyMMdd_HHmmss).txt"
Add-Content -Path $log -Value "Start: $(Get-Date)"
$ports = Get-PnpDevice -Class Ports 2>$null | Where-Object { $
.Manufacturer -like 'FTDI' -and $.InstanceId }
if (-not $ports) { Add-Content $log "No FTDI ports found."; throw "No FTDI ports found (run elevated)" }
foreach ($p in $ports) {
Add-Content $log "----"
Add-Content $log "FriendlyName: $($p.FriendlyName)"
Add-Content $log "InstanceId: $($p.InstanceId)"
$inst = $p.InstanceId
if ([string]::IsNullOrWhiteSpace($inst) {
Add-Content $log "InstanceId empty, skipping"
continue
}
$enumBase = 'HKLM:\SYSTEM\CurrentControlSet\Enum'
$parts = $inst -split '\'
$sub = $parts -join '\'
$regPath = Join-Path $enumBase $sub
$dp = Join-Path $regPath 'Device Parameters'
Add-Content $log "Computed Device Parameters: $dp"
if (Test-Path $dp) {
Add-Content $log "Current properties at $dp:"
Get-ItemProperty -Path $dp | Select-Object DeviceIdleEnabled,DefaultIdleState,UserSetDeviceIdleEnabled,SSIdleTimeout,* | Out-String | Add-Content -Path $log
Code:
try { New-Item -Path $dp -Force | Out-Null New-ItemProperty -Path $dp -Name 'DeviceIdleEnabled' -PropertyType DWord -Value 0 -Force -ErrorAction Stop New-ItemProperty -Path $dp -Name 'DefaultIdleState' -PropertyType DWord -Value 0 -Force -ErrorAction Stop New-ItemProperty -Path $dp -Name 'UserSetDeviceIdleEnabled' -PropertyType DWord -Value 0 -Force -ErrorAction Stop New-ItemProperty -Path $dp -Name 'SSIdleTimeout' -PropertyType DWord -Value 0 -Force -ErrorAction Stop Add-Content $log "WROTE values at $dp"
} catch { Add-Content $log "ERROR writing values at $dp : $($_.Exception.Message)"
}
} else {
Add-Content $log "Device Parameters not found under $regPath. Listing children:"
try { Get-ChildItem -Path $regPath -Recurse -Depth 2 | Select-Object -First 50 | ForEach-Object { Add-Content $log $
.PSPath } } catch { Add-Content $log "Could not enumerate $regPath: $($.Exception.Message)" }
}
}
Add-Content $log "Completed: $(Get-Date)"
Write-Output "Finished. Log: $log"
Troubleshooting tips
- If you still get "Cannot bind argument to parameter 'Path' because it is null", paste the exact command and error — most likely $inst was null or the variable expression inside Join-Path produced null. The script above guards against null and logs the computed path so you can see where it fails.
- Always run as Administrator — writing under HKLM\SYSTEM\CurrentControlSet\Enum needs elevated rights (sometimes SYSTEM/ACL) and will fail silently or with Access Denied otherwise.
- If Test-Path reports not found, the device may have a different instance subkey (e.g., USB\VID_... \6&...&0&0000) — the script’s enumeration output will show the actual subtree so we can target it.
If you paste the exact InstanceId you’re using (the line you got from Get-PnpDevice), I’ll show the exact $dp string you should use and the single New-ItemProperty command to run.