[CmdletBinding()] param( [string]$Csv ) $ErrorActionPreference = 'Stop' $paths = @( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' ) $rows = foreach ($path in $paths) { if (-not (Test-Path -Path $path)) { continue } Get-ItemProperty -Path $path -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName } | ForEach-Object { $sizeMb = $null if ($_.EstimatedSize) { $sizeMb = [math]::Round($_.EstimatedSize / 1024, 2) } [pscustomobject]@{ Name = $_.DisplayName Version = $_.DisplayVersion Publisher = $_.Publisher InstallDate = $_.InstallDate SizeMB = $sizeMb Location = $_.InstallLocation Uninstall = $_.UninstallString } } } $rows = @($rows | Sort-Object Name -Unique) Write-Host ("Программ найдено: {0}" -f $rows.Count) if ($Csv) { $parent = Split-Path -Parent $Csv if ($parent -and -not (Test-Path -LiteralPath $parent)) { New-Item -ItemType Directory -Path $parent | Out-Null } $rows | Export-Csv -LiteralPath $Csv -NoTypeInformation -Encoding UTF8 Write-Host "Отчёт сохранён: $Csv" } else { $rows | Format-Table -AutoSize }