# Установите UTF-8 кодировку для вывода
$OutputEncoding = [System.Text.Encoding]::UTF8
# Имя файла для сохранения отчета
$logfile = "PC_Audit_$(Get-Date -Format 'yyyy_MM_dd_HHmmss').txt"
# Создаем файл отчета
Add-Content -Path $logfile -Value "*** PC Audit Report ***"
Add-Content -Path $logfile -Value "=========================="
Add-Content -Path $logfile -Value "Report Date: $(Get-Date)"
Add-Content -Path $logfile -Value "==========================`n"
# CPU Information
Add-Content -Path $logfile -Value "--- CPU Information ---"
$cpuInfo = Get-CimInstance Win32_Processor
Add-Content -Path $logfile -Value "CPU Name: $($cpuInfo.Name)"
Add-Content -Path $logfile -Value "Number of Cores: $($cpuInfo.NumberOfCores)"
Add-Content -Path $logfile -Value "Number of Logical Processors: $($cpuInfo.NumberOfLogicalProcessors)"
# RAM Information
Add-Content -Path $logfile -Value "`n--- RAM Information ---"
Get-CimInstance Win32_PhysicalMemory | Select-Object Capacity, Speed, BankLabel | ForEach-Object {
[PSCustomObject]@{
CapacityGB = [math]::Round($_.Capacity / 1GB, 2)
Speed = $_.Speed
BankLabel = $_.BankLabel
}
} | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# Motherboard Information
Add-Content -Path $logfile -Value "`n--- Motherboard Information ---"
Get-CimInstance Win32_BaseBoard | Select-Object Manufacturer, Product | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# GPU Information
Add-Content -Path $logfile -Value "`n--- GPU Information ---"
Get-CimInstance Win32_VideoController | Select-Object Name, DriverVersion | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# Disk Drives
Add-Content -Path $logfile -Value "`n--- Disk Drives ---"
Get-CimInstance Win32_DiskDrive | Select-Object Model, @{Name="SizeGB";Expression={[math]::Round($_.Size / 1GB, 2)}} | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# Sound Devices
Add-Content -Path $logfile -Value "`n--- Sound Devices ---"
Get-CimInstance Win32_SoundDevice | Select-Object Name, Manufacturer | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# Network Adapters (с разделением на новые строки)
Add-Content -Path $logfile -Value "`n--- Network Adapters ---"
$networkAdapters = Get-CimInstance Win32_NetworkAdapter | Where-Object { $_.NetEnabled -eq $true }
foreach ($adapter in $networkAdapters) {
Add-Content -Path $logfile -Value "Interface: $($adapter.Name)"
Add-Content -Path $logfile -Value "MAC Address: $($adapter.MACAddress)"
Add-Content -Path $logfile -Value "Speed: $($adapter.Speed)"
Add-Content -Path $logfile -Value "Driver Version: $($adapter.DriverVersion)`n"
}
# Additional Network Interface Information (MAC, Driver Versions)
Add-Content -Path $logfile -Value "`n--- All Network Interfaces and Driver Versions ---"
Get-NetAdapter | Select-Object Name, MacAddress, DriverVersion, Status | ForEach-Object {
Add-Content -Path $logfile -Value "Interface: $($_.Name)"
Add-Content -Path $logfile -Value "MAC Address: $($_.MacAddress)"
Add-Content -Path $logfile -Value "Driver Version: $($_.DriverVersion)"
Add-Content -Path $logfile -Value "Status: $($_.Status)`n"
}
# Internal IP Addresses
Add-Content -Path $logfile -Value "`n--- Internal IP Addresses ---"
Get-NetIPAddress | Where-Object { $_.AddressFamily -eq "IPv4" } | Select-Object IPAddress | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# External IP Address
Add-Content -Path $logfile -Value "`n--- External IP Address ---"
try {
$externalIP = Invoke-RestMethod -Uri "
https://api.ipify.org"
Add-Content -Path $logfile -Value "External IP: $externalIP"
} catch {
Add-Content -Path $logfile -Value "External IP: Could not retrieve"
}
# Установленные программы
Add-Content -Path $logfile -Value "`n--- Installed Software ---"
# Использование Get-Package
$installedSoftware = Get-Package | Select-Object Name, Version
if ($installedSoftware) {
$installedSoftware | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
} else {
Add-Content -Path $logfile -Value "No software found using Get-Package."
}
# Использование реестра
$installedSoftwareFromRegistry = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" `
| Select-Object DisplayName, DisplayVersion
$installedSoftwareFromRegistry += Get-ItemProperty "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" `
| Select-Object DisplayName, DisplayVersion
$installedSoftwareFromRegistry += Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" `
| Select-Object DisplayName, DisplayVersion
if ($installedSoftwareFromRegistry) {
$installedSoftwareFromRegistry | Where-Object { $_.DisplayName } | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
} else {
Add-Content -Path $logfile -Value "No software found in the registry."
}
# Использование WMIC
Add-Content -Path $logfile -Value "`n--- Installed Software (using WMIC) ---"
$wmicSoftware = wmic product get name, version | Out-String
Add-Content -Path $logfile -Value $wmicSoftware
# Running Processes
Add-Content -Path $logfile -Value "`n--- Running Processes ---"
Get-Process | Select-Object Name, Id, CPU, StartTime | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# Active Network Connections
Add-Content -Path $logfile -Value "`n--- Active Network Connections ---"
Get-NetTCPConnection | Format-Table -AutoSize | Out-String | Add-Content -Path $logfile
# Windows Firewall Status (Брандмауэр)
Add-Content -Path $logfile -Value "`n--- Windows Firewall Status ---"
$firewallProfiles = Get-NetFirewallProfile
foreach ($profile in $firewallProfiles) {
Add-Content -Path $logfile -Value "$($profile.Name) Firewall: $($profile.Enabled)"
}
# Check if Windows Defender Real-Time Protection is enabled
Add-Content -Path $logfile -Value "`n--- Windows Defender Status ---"
$defenderStatus = Get-CimInstance -Namespace "root\Microsoft\Windows\Defender" -ClassName MSFT_MpPreference
$defenderRealTimeProtection = $defenderStatus.EnableRealtimeProtection
if ($defenderRealTimeProtection) {
Add-Content -Path $logfile -Value "Real-Time Protection is Enabled."
} else {
Add-Content -Path $logfile -Value "Real-Time Protection is Disabled."
}
# Battery Report (if applicable)
Add-Content -Path $logfile -Value "`n--- Battery Report (if applicable) ---"
if (Get-CimInstance Win32_Battery) {
$batteryReportPath = Join-Path -Path (Get-Location) -ChildPath "battery_report.html"
powercfg /batteryreport /output $batteryReportPath
Add-Content -Path $logfile -Value "Battery report saved to $batteryReportPath"
} else {
Add-Content -Path $logfile -Value "No battery detected."
}
# Информация о системе
Add-Content -Path $logfile -Value "`n--- Windows Version ---"
$windowsVersion = Get-CimInstance Win32_OperatingSystem
Add-Content -Path $logfile -Value "OS Name: $($windowsVersion.Caption)"
Add-Content -Path $logfile -Value "Version: $($windowsVersion.Version)"
Add-Content -Path $logfile -Value "Build Number: $($windowsVersion.BuildNumber)"
Add-Content -Path $logfile -Value "Architecture: $($windowsVersion.OSArchitecture)"