username = os.environ.get('USERNAME') base_path = Path(f'C:/Users/username/AppData/Local/Packages')
distros = [] for line in lines: if line.strip(): parts = line.split() if len(parts) >= 3: distros.append( 'name': parts[0], 'state': parts[1], 'version': parts[2] ) return distros def get_vhdx_path(distribution): """Get VHDX file path for a WSL2 distribution""" package_patterns = 'ubuntu': 'CanonicalGroupLimited.Ubuntu', 'debian': 'TheDebianProject.DebianGNULinux', 'kali': 'KaliLinux',
if not base_path.exists(): return None
if ($packageDir) $vhdxPath = Join-Path $packageDir.FullName "LocalState\ext4.vhdx" if (Test-Path $vhdxPath) Write-Host "WSL2 VHDX Location: $vhdxPath" -ForegroundColor Green # Get file size $file = Get-Item $vhdxPath $sizeGB = [math]::Round($file.Length / 1GB, 2) Write-Host "Size: $sizeGB GB" return $vhdxPath