WMI32_logicalDisk implementent for symbol signs
This commit is contained in:
parent
e7725d0c39
commit
9abe201389
|
|
@ -26,54 +26,37 @@ function Get-Config {
|
||||||
function Get-UNCPath {
|
function Get-UNCPath {
|
||||||
param([string]$LocalPath)
|
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
|
# Wenn der Pfad bereits ein UNC-Pfad ist, direkt zurueckgeben
|
||||||
if ($LocalPath -match '^\\\\') {
|
if ($LocalPath -match '^\\\\') {
|
||||||
"Bereits UNC: $LocalPath" | Out-File $debugFile -Append
|
|
||||||
return $LocalPath
|
return $LocalPath
|
||||||
}
|
}
|
||||||
|
|
||||||
$drive = Split-Path -Path $LocalPath -Qualifier
|
$drive = Split-Path -Path $LocalPath -Qualifier
|
||||||
$driveLetter = $drive.TrimEnd(':')
|
$driveLetter = $drive.TrimEnd(':')
|
||||||
$relativePath = $LocalPath.Substring($drive.Length)
|
$relativePath = $LocalPath.Substring($drive.Length)
|
||||||
"Drive: $drive, Letter: $driveLetter, RelPath: $relativePath" | Out-File $debugFile -Append
|
|
||||||
|
|
||||||
# Methode 1: WMI - zuverlaessigste Methode fuer Netzlaufwerke
|
# Methode 1: WMI - zuverlaessigste Methode fuer Netzlaufwerke
|
||||||
$wmiDrive = Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID='$drive'" -ErrorAction SilentlyContinue
|
$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) {
|
if ($wmiDrive -and $wmiDrive.ProviderName) {
|
||||||
$result = Join-Path $wmiDrive.ProviderName $relativePath
|
return Join-Path $wmiDrive.ProviderName $relativePath
|
||||||
"Result (WMI): $result" | Out-File $debugFile -Append
|
|
||||||
return $result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Methode 2: Get-PSDrive
|
# Methode 2: Get-PSDrive
|
||||||
$psDrive = Get-PSDrive -Name $driveLetter -ErrorAction SilentlyContinue
|
$psDrive = Get-PSDrive -Name $driveLetter -ErrorAction SilentlyContinue
|
||||||
"PSDrive DisplayRoot: $($psDrive.DisplayRoot)" | Out-File $debugFile -Append
|
|
||||||
if ($psDrive -and $psDrive.DisplayRoot) {
|
if ($psDrive -and $psDrive.DisplayRoot) {
|
||||||
$result = Join-Path $psDrive.DisplayRoot $relativePath
|
return Join-Path $psDrive.DisplayRoot $relativePath
|
||||||
"Result (PSDrive): $result" | Out-File $debugFile -Append
|
|
||||||
return $result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Methode 3: Win32_MappedLogicalDisk (speziell fuer gemappte Laufwerke)
|
# Methode 3: Win32_MappedLogicalDisk (speziell fuer gemappte Laufwerke)
|
||||||
$mappedDrive = Get-WmiObject -Class Win32_MappedLogicalDisk -Filter "DeviceID='$drive'" -ErrorAction SilentlyContinue
|
$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) {
|
if ($mappedDrive -and $mappedDrive.ProviderName) {
|
||||||
$result = Join-Path $mappedDrive.ProviderName $relativePath
|
return Join-Path $mappedDrive.ProviderName $relativePath
|
||||||
"Result (MappedDisk): $result" | Out-File $debugFile -Append
|
|
||||||
return $result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fallback: Lokales Laufwerk als Admin-Share
|
# Fallback: Lokales Laufwerk als Admin-Share
|
||||||
$computerName = $env:COMPUTERNAME
|
$computerName = $env:COMPUTERNAME
|
||||||
$adminShare = "\\$computerName\$driveLetter`$"
|
$adminShare = "\\$computerName\$driveLetter`$"
|
||||||
$result = Join-Path $adminShare $relativePath
|
return Join-Path $adminShare $relativePath
|
||||||
"Result (Fallback): $result" | Out-File $debugFile -Append
|
|
||||||
return $result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-DomainUsers {
|
function Get-DomainUsers {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,6 @@
|
||||||
@echo off
|
@echo off
|
||||||
setlocal EnableDelayedExpansion
|
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 "action=%~1"
|
||||||
set "filepath=%~2"
|
set "filepath=%~2"
|
||||||
set "scriptdir=%~dp0"
|
set "scriptdir=%~dp0"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue