# disks.ps1
# Ersatz für: wmic logicaldisk list brief > .\bin\disks.log

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

# Zielpfad wie im Batch
$binDir  = Join-Path -Path (Get-Location) -ChildPath "bin"
$logFile = Join-Path -Path $binDir -ChildPath "disks2.log"

# Ordner anlegen, falls nicht vorhanden
if (-not (Test-Path -LiteralPath $binDir)) {
    New-Item -Path $binDir -ItemType Directory | Out-Null
}

# Logical Disks auslesen (entspricht WMIC logicaldisk list brief)
$disks = Get-CimInstance Win32_LogicalDisk |
    Select-Object `
        DeviceID,
        DriveType,
        FileSystem,
        VolumeName,
        @{n='Size(GB)';       e={[math]::Round($_.Size/1GB,2)}},
        @{n='FreeSpace(GB)'; e={[math]::Round($_.FreeSpace/1GB,2)}}

# Ausgabe nach disks.log (neu schreiben, wie ">")
$disks |
    Format-Table -AutoSize |
    Out-File -FilePath $logFile -Encoding UTF8

Write-Host "Fertig. Log geschrieben nach: $logFile"