I'm using PowerShell version 7.5.2 on Windows 11, and I'm facing issues creating directory symbolic links with relative paths. Whenever I attempt this, the links are not functioning at all—they seem to go nowhere, and the icons appear blank. On the other hand, creating links with absolute paths works perfectly.
Here's the minimal code example:
While working in the directory `C:tmp`, I made directories 'a' and 'b', and in 'b', I wanted to create a symlink to 'a'. Here's what I did:
1. `PS C:tmpa> New-Item -ItemType SymbolicLink -Path . -Name tempnamefolder -Target ....b`
2. `COUT: la--- 2025-08-25 4:30 PM 0 tempnamefolder2 -> ....b`
3. `PS C:tmpa> New-Item -ItemType SymbolicLink -Path . -Name tempnamefolder3 -Target c:tmpb`
4. `COUT: l---- 2025-08-25 4:31 PM tempnamefolder3 -> c:tmpb`
Everything checks out in NTFSLinksView, and directory junctions work fine with relative paths. The only difference I noticed in properties was the 'archivable' attribute. I'm not sure if this is significant. Documentation mentions that PowerShell should allow creating directory symlinks using relative paths since version 7, but I can't seem to get it to work. Any help or insights would be appreciated!
1 Answer
It looks like you might just need to include a `.` at the front of your target path. You should try this:
`New-Item -ItemType SymbolicLink -Path . -Name tempnamefolder -Target ...b`
This way, you're clearly indicating that the target path is relative.

Thanks, this worked! I thought I had tested the `.....b` method, but clearly I wasn't using the right format. It's just confusing because this isn't documented anywhere. Why is this behaviour different for directory symlinks compared to files or junctions?