theohbrothers/ItemLinkManagement

Existing item's check for .Target fails for links with UNC targets

Closed this issue · 0 comments

Issue

Existing item's check for .Target fails for UNC paths due to the Get-Item returned value UNC\* instead of \\* on Windows.

Expectation

Existing item checks for .Target should be able to resolve UNC paths correctly; or alternatively, excluded from the function.

Discussion

Windows

In the following example, .Target of an existing link whose target is a UNC path as returned by Get-Item is UNC\host\target rather than \\host\target.

PS > New-Item -Path C:\link -Value '\\host\target' -ItemType symboliclink -Force
PS > Get-Item C:\link | Select-Object *


PSPath            : Microsoft.PowerShell.Core\FileSystem::C:\link
PSParentPath      : Microsoft.PowerShell.Core\FileSystem::C:\
PSChildName       : link
PSDrive           : C
PSProvider        : Microsoft.PowerShell.Core\FileSystem
PSIsContainer     : True
Mode              : d----l
BaseName          : link
Target            : {UNC\host\target}
LinkType          : SymbolicLink
Name              : link
FullName          : C:\link
Parent            :
Exists            : True
Root              : C:\
Extension         :
CreationTime      : 3/8/2021 20:15:01
CreationTimeUtc   : 3/8/2021 12:15:01
LastAccessTime    : 3/8/2021 20:15:01
LastAccessTimeUtc : 3/8/2021 12:15:01
LastWriteTime     : 3/8/2021 20:15:01
LastWriteTimeUtc  : 3/8/2021 12:15:01
Attributes        : Directory, ReparsePoint

*nix

Unknown.