From 5bb00b63e5c7d1ea22511611a7f52d89d32e845a Mon Sep 17 00:00:00 2001 From: duffyduck Date: Wed, 7 Jan 2026 15:29:08 +0100 Subject: [PATCH] debug unc qualifier --- Freigabe-Hinzufuegen.ps1 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Freigabe-Hinzufuegen.ps1 b/Freigabe-Hinzufuegen.ps1 index 16782c2..ebc0895 100644 --- a/Freigabe-Hinzufuegen.ps1 +++ b/Freigabe-Hinzufuegen.ps1 @@ -25,12 +25,17 @@ function Get-Config { function Get-UNCPath { param([string]$LocalPath) - + + # Wenn der Pfad bereits ein UNC-Pfad ist, direkt zurueckgeben + if ($LocalPath -match '^\\\\') { + return $LocalPath + } + $drive = Split-Path -Path $LocalPath -Qualifier $driveLetter = $drive.TrimEnd(':') - + $netUse = net use 2>$null | Where-Object { $_ -match "^\s*\w*\s+$driveLetter`:" } - + if ($netUse) { $parts = $netUse -split '\s+' foreach ($part in $parts) { @@ -41,19 +46,19 @@ function Get-UNCPath { } } } - + $psDrive = Get-PSDrive -Name $driveLetter -ErrorAction SilentlyContinue if ($psDrive -and $psDrive.DisplayRoot) { $relativePath = $LocalPath.Substring($drive.Length) return Join-Path $psDrive.DisplayRoot $relativePath } - + $wmiDrive = Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID='$drive'" -ErrorAction SilentlyContinue if ($wmiDrive -and $wmiDrive.ProviderName) { $relativePath = $LocalPath.Substring($drive.Length) return Join-Path $wmiDrive.ProviderName $relativePath } - + $computerName = $env:COMPUTERNAME $adminShare = "\\$computerName\$driveLetter`$" $relativePath = $LocalPath.Substring($drive.Length)