PowerShell: path or item not found
Documentation: Microsoft Learn
Find incorrect paths, unexpected working directories and wildcard interpretation when PowerShell cannot locate an item.
What it means
PowerShell could not resolve the requested provider item. The target may be a file, directory, registry key or another provider path. Confirm the full path and working directory; a prior existence check cannot prevent the item changing before it is used.
Likely causes
- A typo or the wrong drive qualifier in the path
- A relative path resolved against a working directory you did not expect
- The path contains square brackets, which PowerShell reads as a wildcard character class
- The registry key exists only under the 32-bit Wow6432Node view
- Another process removed or renamed the target between your check and your use of it
Check
Run these checks before changing anything.
What these checks establish
False from Test-Path means the supplied item was not found through that check; inspect any access or provider errors as well. Get-Location helps explain an unexpected relative path.
Fix
Resolve the intended full path and check each relevant segment. Use -LiteralPath when brackets or other wildcard characters belong to the actual name. In a script, build paths relative to the intended base, often $PSScriptRoot, instead of assuming the caller’s current directory. Handle failure on the actual read or write because existence can change after a check.
Verify: Run from both the expected and a different working directory; confirm the same intended item is used.