[CmdletBinding()] param( [string]$OutDir = '.' ) $ErrorActionPreference = 'Stop' if (-not (Test-Path -LiteralPath $OutDir -PathType Container)) { New-Item -ItemType Directory -Path $OutDir | Out-Null } $drivers = @(Get-CimInstance -ClassName Win32_PnPSignedDriver -ErrorAction Stop | Select-Object DeviceName, DeviceID, DriverVersion, @{Name = 'DriverDate'; Expression = { if ($_.DriverDate) { $_.DriverDate.ToString('yyyy-MM-dd') } else { '' } }}, DriverProviderName, Signer, InfName | Sort-Object DeviceName) $problem = @(Get-CimInstance -ClassName Win32_PnPEntity -ErrorAction Stop | Where-Object { $_.ConfigManagerErrorCode -ne 0 } | Select-Object Name, DeviceID, Status, ConfigManagerErrorCode, PNPClass | Sort-Object Name) $driverFile = Join-Path $OutDir 'drivers.csv' $problemFile = Join-Path $OutDir 'problem-devices.csv' $drivers | Export-Csv -LiteralPath $driverFile -NoTypeInformation -Encoding UTF8 $problem | Export-Csv -LiteralPath $problemFile -NoTypeInformation -Encoding UTF8 Write-Host ("Драйверов: {0}, проблемных устройств: {1}" -f $drivers.Count, $problem.Count) Write-Host "Сохранено: $driverFile" Write-Host "Сохранено: $problemFile"