debug unc qualifier
This commit is contained in:
parent
479b365ebb
commit
5bb00b63e5
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue