I’ve wanted to programmaticly lable symlinks since a decade. Found some time on how to get that done.
COM Interface Method
$a = New-Object -ComObject shell.application
$a.NameSpace("Z:").self.name = "dump"
PowerShell Native Method
New-Item -ItemType SymbolicLink -Path "Z:" -Target "C:\dump"
Set-ItemProperty -Path "Z:" -Name "Label" -Value "dump"
Error Handling
try {
$a = New-Object -ComObject shell.application
$a.NameSpace("Z:").self.name = "dump"
} catch {
Write-Error "Failed to set symlink label: $_"
}
- Verification
# Verify the label
$a.NameSpace("Z:").self.name