Fixes · Checked on 2026-10-07, with PowerShell 5.1 and 7.6
Get-Content : Cannot find path because it does not exist
The file is somewhere else, the path is read from another folder, or its name has brackets.
The error
PS C:\work\app> Get-Content src\config.ts
Get-Content : Cannot find path 'C:\work\app\src\config.ts' because it does not exist.
PowerShell 7 writes Get-Content: with no space before the colon. Get-ChildItem,
Get-Item, Copy-Item, Remove-Item and Set-Location give the same message.
Why it happens
The file isn't there. This is the usual one, and the one coding agents hit most: they guess
where a file lives, src\config.ts when it's apps\web\src\config.ts, and read it
without looking first. The full path in the message shows exactly where PowerShell looked.
A relative path, read from another folder. PowerShell resolves it against its current
location, which Set-Location (cd) changes. .NET methods don't follow
Set-Location: after cd sub, Get-Content notes.txt reads
sub\notes.txt, but [IO.File]::ReadAllText('notes.txt') looks in the folder PowerShell
started in, and fails with Could not find file.
Brackets in the name. A path is a wildcard pattern, and [1] matches the character
1, so notes[1].txt never matches itself. The message is a different one:
PS> Get-Content 'notes[1].txt'
Get-Content : An object at the specified path notes[1].txt does not exist, or has been filtered by the -Include or
-Exclude parameter.
Test-Path 'notes[1].txt' says False too, though the file is there.
The fix
Look before you read, and find the file by its name when the path is a guess:
Test-Path src\config.ts # False: the path is wrong
Get-ChildItem -Recurse -Filter config.ts | Select-Object FullName
rg --files | rg config.ts # quicker in a big repo
For a name with brackets, turn the wildcards off:
Get-Content -LiteralPath 'notes[1].txt'
Test-Path -LiteralPath 'notes[1].txt' # True
Before passing a relative path to a .NET method, make it a full one:
[IO.File]::ReadAllText((Resolve-Path notes.txt).Path)
How DMN learned it
It's the error our own agents hit most: DMN keeps eight lessons about it, from 39 sessions across two
repositories. The one from 12 sessions:
In the IDE Studio repo, don't guess file paths for Get-Content; confirm the file exists first with `rg
--files | rg <name>` or `Get-ChildItem -Recurse -Filter <name>`.
DMN reads your agents' past sessions on your machine. When the same error is fixed the same way in two or more of them, it keeps the fix as a one-line lesson. When the error turns up again, Claude Code is told the fix straight away, and any agent can search what earlier sessions found. How DMN keeps what agents learn.