WMI32_logicalDisk implementent for symbol signs

This commit is contained in:
duffyduck 2026-01-07 16:08:28 +01:00
parent e7725d0c39
commit 9abe201389
2 changed files with 4 additions and 28 deletions

View File

@ -26,54 +26,37 @@ function Get-Config {
function Get-UNCPath {
param([string]$LocalPath)
# DEBUG
$debugFile = "$env:TEMP\freigabe_unc_debug.txt"
"Input: $LocalPath" | Out-File $debugFile
# Wenn der Pfad bereits ein UNC-Pfad ist, direkt zurueckgeben
if ($LocalPath -match '^\\\\') {
"Bereits UNC: $LocalPath" | Out-File $debugFile -Append
return $LocalPath
}
$drive = Split-Path -Path $LocalPath -Qualifier
$driveLetter = $drive.TrimEnd(':')
$relativePath = $LocalPath.Substring($drive.Length)
"Drive: $drive, Letter: $driveLetter, RelPath: $relativePath" | Out-File $debugFile -Append
# Methode 1: WMI - zuverlaessigste Methode fuer Netzlaufwerke
$wmiDrive = Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID='$drive'" -ErrorAction SilentlyContinue
"WMI LogicalDisk ProviderName: $($wmiDrive.ProviderName)" | Out-File $debugFile -Append
if ($wmiDrive -and $wmiDrive.ProviderName) {
$result = Join-Path $wmiDrive.ProviderName $relativePath
"Result (WMI): $result" | Out-File $debugFile -Append
return $result
return Join-Path $wmiDrive.ProviderName $relativePath
}
# Methode 2: Get-PSDrive
$psDrive = Get-PSDrive -Name $driveLetter -ErrorAction SilentlyContinue
"PSDrive DisplayRoot: $($psDrive.DisplayRoot)" | Out-File $debugFile -Append
if ($psDrive -and $psDrive.DisplayRoot) {
$result = Join-Path $psDrive.DisplayRoot $relativePath
"Result (PSDrive): $result" | Out-File $debugFile -Append
return $result
return Join-Path $psDrive.DisplayRoot $relativePath
}
# Methode 3: Win32_MappedLogicalDisk (speziell fuer gemappte Laufwerke)
$mappedDrive = Get-WmiObject -Class Win32_MappedLogicalDisk -Filter "DeviceID='$drive'" -ErrorAction SilentlyContinue
"WMI MappedLogicalDisk ProviderName: $($mappedDrive.ProviderName)" | Out-File $debugFile -Append
if ($mappedDrive -and $mappedDrive.ProviderName) {
$result = Join-Path $mappedDrive.ProviderName $relativePath
"Result (MappedDisk): $result" | Out-File $debugFile -Append
return $result
return Join-Path $mappedDrive.ProviderName $relativePath
}
# Fallback: Lokales Laufwerk als Admin-Share
$computerName = $env:COMPUTERNAME
$adminShare = "\\$computerName\$driveLetter`$"
$result = Join-Path $adminShare $relativePath
"Result (Fallback): $result" | Out-File $debugFile -Append
return $result
return Join-Path $adminShare $relativePath
}
function Get-DomainUsers {

View File

@ -1,13 +1,6 @@
@echo off
setlocal EnableDelayedExpansion
REM DEBUG: Zeige was ankommt
echo Argument 1: %~1 > "%TEMP%\freigabe_debug.txt"
echo Argument 2: %~2 >> "%TEMP%\freigabe_debug.txt"
echo Argument 3: %~3 >> "%TEMP%\freigabe_debug.txt"
echo Argument 4: %~4 >> "%TEMP%\freigabe_debug.txt"
echo Alle Args: %* >> "%TEMP%\freigabe_debug.txt"
set "action=%~1"
set "filepath=%~2"
set "scriptdir=%~dp0"