1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| $lxss = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss"
Get-ChildItem $lxss | ForEach-Object { $keyGuid = $_.PSChildName $p = Get-ItemProperty $_.PsPath
$base = $p.BasePath if ($base -like "\\?\*") { $base = $base.Substring(4) } # 去掉 \\?\
$vhdxs = @() if (Test-Path -LiteralPath $base) { $vhdxs = Get-ChildItem -LiteralPath $base -Filter *.vhdx -File -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName }
[PSCustomObject]@{ Name = $p.DistributionName Version = $p.Version KeyGuid = $keyGuid BasePath = $base VHDXs = ($vhdxs -join "; ") } } | Sort-Object Name | Format-Table -AutoSize
|