From 5f28527ff2de0e87578b851615b93e22ece66b6c Mon Sep 17 00:00:00 2001 From: devops Date: Thu, 26 Feb 2026 09:23:13 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9A=D1=80=D0=B8=D0=BF=D1=82=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=81=D0=B1=D0=BE=D1=80=D0=B0=20=D0=B8=D0=BD=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=20=D0=9F?= =?UTF-8?q?=D0=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Get-FullHWInventory.ps1 | 686 ++++++++++++++++++++-------------------- 1 file changed, 343 insertions(+), 343 deletions(-) diff --git a/Get-FullHWInventory.ps1 b/Get-FullHWInventory.ps1 index 0fa8d28..daf3f8d 100644 --- a/Get-FullHWInventory.ps1 +++ b/Get-FullHWInventory.ps1 @@ -1,344 +1,344 @@ -# Get-FullHWInventory.ps1 - ВЕРСИЯ ДЛЯ СОХРАНЕНИЯ В XML - -# Переменные -$Computer = $env:COMPUTERNAME -$User = $env:USERNAME -$Date = Get-Date -Format "yyyy-MM-dd HH:mm:ss" - -Write-Host "Собираем информацию о системе для $Computer..." -ForegroundColor Yellow - -# Функция для получения установленного ПО -function Get-InstalledSoftware { - $software = @() - - # Из реестра (32-bit и 64-bit программы) - $paths = @( - "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", - "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" - ) - - foreach ($path in $paths) { - if (Test-Path $path) { - $software += Get-ItemProperty $path | - Where-Object { $_.DisplayName -and $_.DisplayName -notlike "*Update for*" -and $_.DisplayName -notlike "*KB*" } | - Select-Object @{Name="Name";Expression={$_.DisplayName}}, - @{Name="Version";Expression={$_.DisplayVersion}}, - @{Name="Publisher";Expression={$_.Publisher}}, - @{Name="InstallDate";Expression={$_.InstallDate}}, - @{Name="UninstallString";Expression={$_.UninstallString}} - } - } - - # Сортируем и возвращаем - return ($software | Sort-Object Name | Select-Object -First 100) -} - -# Функция для получения сервисов -function Get-ServiceInfo { - return (Get-Service | Where-Object { $_.Status -eq "Running" } | Select-Object Name, DisplayName, Status | Sort-Object Name) -} - -# Функция для получения процессов -function Get-ProcessInfo { - return (Get-Process | Select-Object Name, CPU, WorkingSet, StartTime | Sort-Object CPU -Descending | Select-Object -First 50) -} - -# Сбор основной информации о системе -Write-Host "Сбор информации об оборудовании..." -ForegroundColor Yellow -$CS = Get-WmiObject -Class Win32_ComputerSystem -$OS = Get-WmiObject -Class Win32_OperatingSystem -$Proc = Get-WmiObject -Class Win32_Processor -$RAM = [math]::Round($CS.TotalPhysicalMemory / 1GB, 2) -$Motherboard = Get-WmiObject -Class Win32_BaseBoard -$BIOS = Get-WmiObject -Class Win32_BIOS - -# Сбор информации о дисках -$diskList = @() -$disks = Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" -foreach ($disk in $disks) { - $diskInfo = [PSCustomObject]@{ - Drive = $disk.DeviceID - SizeGB = [math]::Round($disk.Size/1GB, 0) - FreeSpaceGB = [math]::Round($disk.FreeSpace/1GB, 0) - FileSystem = $disk.FileSystem - VolumeName = $disk.VolumeName - } - $diskList += $diskInfo -} - -# Физические диски -$physicalDiskList = @() -$physDisks = Get-WmiObject -Class Win32_DiskDrive -foreach ($physDisk in $physDisks) { - $physDiskInfo = [PSCustomObject]@{ - Model = $physDisk.Model - SizeGB = [math]::Round($physDisk.Size/1GB, 0) - InterfaceType = $physDisk.InterfaceType - SerialNumber = $physDisk.SerialNumber - } - $physicalDiskList += $physDiskInfo -} - -# Видеокарта -$videoList = @() -$videoCards = Get-WmiObject -Class Win32_VideoController -foreach ($video in $videoCards) { - $videoInfo = [PSCustomObject]@{ - Name = $video.Name - RAM = if ($video.AdapterRAM) { [math]::Round($video.AdapterRAM/1MB, 0) } else { 0 } - DriverVersion = $video.DriverVersion - RefreshRate = $video.CurrentRefreshRate - } - $videoList += $videoInfo -} - -# Сетевые адаптеры -$networkList = @() -$netAdapters = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true } -foreach ($netAdapter in $netAdapters) { - $netName = (Get-WmiObject -Class Win32_NetworkAdapter | Where-Object { $_.Index -eq $netAdapter.Index }).Name - $networkInfo = [PSCustomObject]@{ - Name = $netName - IPAddress = $netAdapter.IPAddress -join ", " - MACAddress = $netAdapter.MACAddress - DHCPEnabled = $netAdapter.DHCPEnabled - DNSServers = $netAdapter.DNSServerSearchOrder -join ", " - } - $networkList += $networkInfo -} - -# Мониторы -$monitorList = @() -try { - $monitors = Get-WmiObject -Class WmiMonitorID -Namespace root\wmi -ErrorAction SilentlyContinue - foreach ($monitor in $monitors) { - $manufacturer = if ($monitor.ManufacturerName) { - [System.Text.Encoding]::ASCII.GetString($monitor.ManufacturerName -ne 0) - } else { "Unknown" } - $name = if ($monitor.UserFriendlyName) { - [System.Text.Encoding]::ASCII.GetString($monitor.UserFriendlyName -ne 0) - } else { "Unknown" } - $serial = if ($monitor.SerialNumberID) { - [System.Text.Encoding]::ASCII.GetString($monitor.SerialNumberID -ne 0) - } else { "Unknown" } - - $monitorInfo = [PSCustomObject]@{ - Manufacturer = $manufacturer - Name = $name - SerialNumber = $serial - YearOfManufacture = $monitor.YearOfManufacture - } - $monitorList += $monitorInfo - } -} -catch { - Write-Host "⚠️ Не удалось получить информацию о мониторах" -ForegroundColor Yellow -} - -# Принтеры -$printerList = @() -$printers = Get-WmiObject -Class Win32_Printer | Where-Object { - $_.Name -notlike "*Microsoft*" -and - $_.Name -notlike "*OneNote*" -and - $_.Name -notlike "*Fax*" -and - $_.Name -notlike "*XPS*" -} -foreach ($printer in $printers) { - $printerInfo = [PSCustomObject]@{ - Name = $printer.Name - Default = $printer.Default - Network = $printer.Network - DriverName = $printer.DriverName - PortName = $printer.PortName - Shared = $printer.Shared - } - $printerList += $printerInfo -} - -# USB устройства -$usbList = @() -try { - $usbDevices = Get-WmiObject -Class Win32_USBControllerDevice | ForEach-Object { [wmi]($_.Dependent) } - $uniqueUSB = $usbDevices | Where-Object { - $_.Name -and - $_.Name -notlike "*USB Root Hub*" -and - $_.Name -notlike "*Generic USB Hub*" - } | Select-Object -Unique Name, Description, Manufacturer - foreach ($device in $uniqueUSB) { - $usbInfo = [PSCustomObject]@{ - Name = $device.Name - Description = $device.Description - Manufacturer = $device.Manufacturer - } - $usbList += $usbInfo - } -} -catch { - Write-Host "⚠️ Не удалось получить информацию о USB устройствах" -ForegroundColor Yellow -} - -# Клавиатуры и мыши -$mouseList = @() -$mice = Get-WmiObject -Class Win32_PointingDevice -foreach ($mouse in $mice) { - $mouseInfo = [PSCustomObject]@{ - Name = $mouse.Name - Manufacturer = $mouse.Manufacturer - HardwareType = $mouse.HardwareType - NumberOfButtons = $mouse.NumberOfButtons - } - $mouseList += $mouseInfo -} - -$keyboardList = @() -$keyboards = Get-WmiObject -Class Win32_Keyboard -foreach ($keyboard in $keyboards) { - $keyboardInfo = [PSCustomObject]@{ - Name = $keyboard.Name - Description = $keyboard.Description - } - $keyboardList += $keyboardInfo -} - -# Установленное ПО -Write-Host "Сбор информации об установленном ПО..." -ForegroundColor Yellow -$InstalledSoftware = Get-InstalledSoftware - -# Сервисы -Write-Host "Сбор информации о сервисах..." -ForegroundColor Yellow -$Services = Get-ServiceInfo - -# Процессы -Write-Host "Сбор информации о процессах..." -ForegroundColor Yellow -$Processes = Get-ProcessInfo - -# Создаем главный объект со всей информацией -$Inventory = [PSCustomObject]@{ - # Информация о сборе - ScanInfo = [PSCustomObject]@{ - Date = $Date - ComputerName = $Computer - UserName = $User - ScanVersion = "1.0" - } - - # Системная информация - SystemInfo = [PSCustomObject]@{ - Manufacturer = $CS.Manufacturer - Model = $CS.Model - SerialNumber = $BIOS.SerialNumber - Motherboard = "$($Motherboard.Manufacturer) $($Motherboard.Product)" - BIOSVersion = $BIOS.SMBIOSBIOSVersion - BIOSDate = $BIOS.ReleaseDate - } - - # Процессоры - Processors = $Proc | ForEach-Object { - [PSCustomObject]@{ - Name = $_.Name - Cores = $_.NumberOfCores - LogicalProcessors = $_.NumberOfLogicalProcessors - MaxClockSpeed = $_.MaxClockSpeed - Socket = $_.SocketDesignation - } - } - - # Оперативная память - RAM = @{ - TotalGB = $RAM - # Можно добавить информацию по каждому модулю - } - - # Диски - LogicalDisks = $diskList - PhysicalDisks = $physicalDiskList - - # Видеокарты - VideoCards = $videoList - - # Сеть - NetworkAdapters = $networkList - - # Периферия - Peripherals = [PSCustomObject]@{ - Monitors = $monitorList - Printers = $printerList - Keyboards = $keyboardList - Mice = $mouseList - USBDevices = $usbList - } - - # Операционная система - OperatingSystem = [PSCustomObject]@{ - Name = $OS.Caption - Version = $OS.Version - Architecture = $OS.OSArchitecture - InstallDate = $OS.InstallDate - LastBootTime = $OS.LastBootUpTime - RegisteredUser = $OS.RegisteredUser - Organization = $OS.Organization - SerialNumber = $OS.SerialNumber - } - - # Установленное ПО - InstalledSoftware = $InstalledSoftware - - # Сервисы - Services = $Services - - # Процессы - Processes = $Processes -} - -# СОХРАНЯЕМ В XML -Write-Host "Сохранение данных в XML..." -ForegroundColor Yellow - -try { - # Создаем папку, если её нет - $saveDir = "C:\ProgramData\Inventory" - if (-not (Test-Path $saveDir)) { - New-Item -ItemType Directory -Path $saveDir -Force | Out-Null - } - - # Формируем имя файла с датой - $dateStr = Get-Date -Format "yyyyMMdd_HHmmss" - $savePath = "$saveDir\Inventory_${Computer}_${dateStr}.xml" - - # Сохраняем в XML - $Inventory | Export-Clixml -Path $savePath -Depth 5 - - Write-Host "✅ Данные успешно сохранены в: $savePath" -ForegroundColor Green - Write-Host " Размер файла: $([math]::Round((Get-Item $savePath).Length/1KB, 2)) KB" -ForegroundColor Green - - # Создаем симлинк или копию с постоянным именем для удобства - $latestPath = "$saveDir\Inventory_$Computer-latest.xml" - if (Test-Path $latestPath) { - Remove-Item $latestPath -Force - } - Copy-Item $savePath -Destination $latestPath - Write-Host " 📎 Последняя версия: $latestPath" -ForegroundColor Cyan -} -catch { - Write-Host "❌ Ошибка при сохранении XML: $_" -ForegroundColor Red - - # Пробуем сохранить в корень C:\ - try { - $savePath = "C:\Inventory_${Computer}_$(Get-Date -Format 'yyyyMMdd_HHmmss').xml" - $Inventory | Export-Clixml -Path $savePath -Depth 5 - Write-Host "✅ Данные сохранены в: $savePath" -ForegroundColor Yellow - } - catch { - Write-Host "❌ Критическая ошибка сохранения: $_" -ForegroundColor Red - } -} - -# Показываем статистику -Write-Host "`n📊 Статистика сбора:" -ForegroundColor Cyan -Write-Host " - Программ установлено: $($Inventory.InstalledSoftware.Count)" -ForegroundColor White -Write-Host " - Сервисов запущено: $($Inventory.Services.Count)" -ForegroundColor White -Write-Host " - Процессов: $($Inventory.Processes.Count)" -ForegroundColor White -Write-Host " - Дисков: $($Inventory.LogicalDisks.Count)" -ForegroundColor White -Write-Host " - Сетевых адаптеров: $($Inventory.NetworkAdapters.Count)" -ForegroundColor White -Write-Host " - USB устройств: $($Inventory.Peripherals.USBDevices.Count)" -ForegroundColor White - +# Get-FullHWInventory.ps1 - ВЕРСИЯ ДЛЯ СОХРАНЕНИЯ В XML! + +# Переменные +$Computer = $env:COMPUTERNAME +$User = $env:USERNAME +$Date = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + +Write-Host "Собираем информацию о системе для $Computer..." -ForegroundColor Yellow + +# Функция для получения установленного ПО +function Get-InstalledSoftware { + $software = @() + + # Из реестра (32-bit и 64-bit программы) + $paths = @( + "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", + "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" + ) + + foreach ($path in $paths) { + if (Test-Path $path) { + $software += Get-ItemProperty $path | + Where-Object { $_.DisplayName -and $_.DisplayName -notlike "*Update for*" -and $_.DisplayName -notlike "*KB*" } | + Select-Object @{Name="Name";Expression={$_.DisplayName}}, + @{Name="Version";Expression={$_.DisplayVersion}}, + @{Name="Publisher";Expression={$_.Publisher}}, + @{Name="InstallDate";Expression={$_.InstallDate}}, + @{Name="UninstallString";Expression={$_.UninstallString}} + } + } + + # Сортируем и возвращаем + return ($software | Sort-Object Name | Select-Object -First 100) +} + +# Функция для получения сервисов +function Get-ServiceInfo { + return (Get-Service | Where-Object { $_.Status -eq "Running" } | Select-Object Name, DisplayName, Status | Sort-Object Name) +} + +# Функция для получения процессов +function Get-ProcessInfo { + return (Get-Process | Select-Object Name, CPU, WorkingSet, StartTime | Sort-Object CPU -Descending | Select-Object -First 50) +} + +# Сбор основной информации о системе +Write-Host "Сбор информации об оборудовании..." -ForegroundColor Yellow +$CS = Get-WmiObject -Class Win32_ComputerSystem +$OS = Get-WmiObject -Class Win32_OperatingSystem +$Proc = Get-WmiObject -Class Win32_Processor +$RAM = [math]::Round($CS.TotalPhysicalMemory / 1GB, 2) +$Motherboard = Get-WmiObject -Class Win32_BaseBoard +$BIOS = Get-WmiObject -Class Win32_BIOS + +# Сбор информации о дисках +$diskList = @() +$disks = Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" +foreach ($disk in $disks) { + $diskInfo = [PSCustomObject]@{ + Drive = $disk.DeviceID + SizeGB = [math]::Round($disk.Size/1GB, 0) + FreeSpaceGB = [math]::Round($disk.FreeSpace/1GB, 0) + FileSystem = $disk.FileSystem + VolumeName = $disk.VolumeName + } + $diskList += $diskInfo +} + +# Физические диски +$physicalDiskList = @() +$physDisks = Get-WmiObject -Class Win32_DiskDrive +foreach ($physDisk in $physDisks) { + $physDiskInfo = [PSCustomObject]@{ + Model = $physDisk.Model + SizeGB = [math]::Round($physDisk.Size/1GB, 0) + InterfaceType = $physDisk.InterfaceType + SerialNumber = $physDisk.SerialNumber + } + $physicalDiskList += $physDiskInfo +} + +# Видеокарта +$videoList = @() +$videoCards = Get-WmiObject -Class Win32_VideoController +foreach ($video in $videoCards) { + $videoInfo = [PSCustomObject]@{ + Name = $video.Name + RAM = if ($video.AdapterRAM) { [math]::Round($video.AdapterRAM/1MB, 0) } else { 0 } + DriverVersion = $video.DriverVersion + RefreshRate = $video.CurrentRefreshRate + } + $videoList += $videoInfo +} + +# Сетевые адаптеры +$networkList = @() +$netAdapters = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true } +foreach ($netAdapter in $netAdapters) { + $netName = (Get-WmiObject -Class Win32_NetworkAdapter | Where-Object { $_.Index -eq $netAdapter.Index }).Name + $networkInfo = [PSCustomObject]@{ + Name = $netName + IPAddress = $netAdapter.IPAddress -join ", " + MACAddress = $netAdapter.MACAddress + DHCPEnabled = $netAdapter.DHCPEnabled + DNSServers = $netAdapter.DNSServerSearchOrder -join ", " + } + $networkList += $networkInfo +} + +# Мониторы +$monitorList = @() +try { + $monitors = Get-WmiObject -Class WmiMonitorID -Namespace root\wmi -ErrorAction SilentlyContinue + foreach ($monitor in $monitors) { + $manufacturer = if ($monitor.ManufacturerName) { + [System.Text.Encoding]::ASCII.GetString($monitor.ManufacturerName -ne 0) + } else { "Unknown" } + $name = if ($monitor.UserFriendlyName) { + [System.Text.Encoding]::ASCII.GetString($monitor.UserFriendlyName -ne 0) + } else { "Unknown" } + $serial = if ($monitor.SerialNumberID) { + [System.Text.Encoding]::ASCII.GetString($monitor.SerialNumberID -ne 0) + } else { "Unknown" } + + $monitorInfo = [PSCustomObject]@{ + Manufacturer = $manufacturer + Name = $name + SerialNumber = $serial + YearOfManufacture = $monitor.YearOfManufacture + } + $monitorList += $monitorInfo + } +} +catch { + Write-Host "⚠️ Не удалось получить информацию о мониторах" -ForegroundColor Yellow +} + +# Принтеры +$printerList = @() +$printers = Get-WmiObject -Class Win32_Printer | Where-Object { + $_.Name -notlike "*Microsoft*" -and + $_.Name -notlike "*OneNote*" -and + $_.Name -notlike "*Fax*" -and + $_.Name -notlike "*XPS*" +} +foreach ($printer in $printers) { + $printerInfo = [PSCustomObject]@{ + Name = $printer.Name + Default = $printer.Default + Network = $printer.Network + DriverName = $printer.DriverName + PortName = $printer.PortName + Shared = $printer.Shared + } + $printerList += $printerInfo +} + +# USB устройства +$usbList = @() +try { + $usbDevices = Get-WmiObject -Class Win32_USBControllerDevice | ForEach-Object { [wmi]($_.Dependent) } + $uniqueUSB = $usbDevices | Where-Object { + $_.Name -and + $_.Name -notlike "*USB Root Hub*" -and + $_.Name -notlike "*Generic USB Hub*" + } | Select-Object -Unique Name, Description, Manufacturer + foreach ($device in $uniqueUSB) { + $usbInfo = [PSCustomObject]@{ + Name = $device.Name + Description = $device.Description + Manufacturer = $device.Manufacturer + } + $usbList += $usbInfo + } +} +catch { + Write-Host "⚠️ Не удалось получить информацию о USB устройствах" -ForegroundColor Yellow +} + +# Клавиатуры и мыши +$mouseList = @() +$mice = Get-WmiObject -Class Win32_PointingDevice +foreach ($mouse in $mice) { + $mouseInfo = [PSCustomObject]@{ + Name = $mouse.Name + Manufacturer = $mouse.Manufacturer + HardwareType = $mouse.HardwareType + NumberOfButtons = $mouse.NumberOfButtons + } + $mouseList += $mouseInfo +} + +$keyboardList = @() +$keyboards = Get-WmiObject -Class Win32_Keyboard +foreach ($keyboard in $keyboards) { + $keyboardInfo = [PSCustomObject]@{ + Name = $keyboard.Name + Description = $keyboard.Description + } + $keyboardList += $keyboardInfo +} + +# Установленное ПО +Write-Host "Сбор информации об установленном ПО..." -ForegroundColor Yellow +$InstalledSoftware = Get-InstalledSoftware + +# Сервисы +Write-Host "Сбор информации о сервисах..." -ForegroundColor Yellow +$Services = Get-ServiceInfo + +# Процессы +Write-Host "Сбор информации о процессах..." -ForegroundColor Yellow +$Processes = Get-ProcessInfo + +# Создаем главный объект со всей информацией +$Inventory = [PSCustomObject]@{ + # Информация о сборе + ScanInfo = [PSCustomObject]@{ + Date = $Date + ComputerName = $Computer + UserName = $User + ScanVersion = "1.0" + } + + # Системная информация + SystemInfo = [PSCustomObject]@{ + Manufacturer = $CS.Manufacturer + Model = $CS.Model + SerialNumber = $BIOS.SerialNumber + Motherboard = "$($Motherboard.Manufacturer) $($Motherboard.Product)" + BIOSVersion = $BIOS.SMBIOSBIOSVersion + BIOSDate = $BIOS.ReleaseDate + } + + # Процессоры + Processors = $Proc | ForEach-Object { + [PSCustomObject]@{ + Name = $_.Name + Cores = $_.NumberOfCores + LogicalProcessors = $_.NumberOfLogicalProcessors + MaxClockSpeed = $_.MaxClockSpeed + Socket = $_.SocketDesignation + } + } + + # Оперативная память + RAM = @{ + TotalGB = $RAM + # Можно добавить информацию по каждому модулю + } + + # Диски + LogicalDisks = $diskList + PhysicalDisks = $physicalDiskList + + # Видеокарты + VideoCards = $videoList + + # Сеть + NetworkAdapters = $networkList + + # Периферия + Peripherals = [PSCustomObject]@{ + Monitors = $monitorList + Printers = $printerList + Keyboards = $keyboardList + Mice = $mouseList + USBDevices = $usbList + } + + # Операционная система + OperatingSystem = [PSCustomObject]@{ + Name = $OS.Caption + Version = $OS.Version + Architecture = $OS.OSArchitecture + InstallDate = $OS.InstallDate + LastBootTime = $OS.LastBootUpTime + RegisteredUser = $OS.RegisteredUser + Organization = $OS.Organization + SerialNumber = $OS.SerialNumber + } + + # Установленное ПО + InstalledSoftware = $InstalledSoftware + + # Сервисы + Services = $Services + + # Процессы + Processes = $Processes +} + +# СОХРАНЯЕМ В XML +Write-Host "Сохранение данных в XML..." -ForegroundColor Yellow + +try { + # Создаем папку, если её нет + $saveDir = "C:\ProgramData\Inventory" + if (-not (Test-Path $saveDir)) { + New-Item -ItemType Directory -Path $saveDir -Force | Out-Null + } + + # Формируем имя файла с датой + $dateStr = Get-Date -Format "yyyyMMdd_HHmmss" + $savePath = "$saveDir\Inventory_${Computer}_${dateStr}.xml" + + # Сохраняем в XML + $Inventory | Export-Clixml -Path $savePath -Depth 5 + + Write-Host "✅ Данные успешно сохранены в: $savePath" -ForegroundColor Green + Write-Host " Размер файла: $([math]::Round((Get-Item $savePath).Length/1KB, 2)) KB" -ForegroundColor Green + + # Создаем симлинк или копию с постоянным именем для удобства + $latestPath = "$saveDir\Inventory_$Computer-latest.xml" + if (Test-Path $latestPath) { + Remove-Item $latestPath -Force + } + Copy-Item $savePath -Destination $latestPath + Write-Host " 📎 Последняя версия: $latestPath" -ForegroundColor Cyan +} +catch { + Write-Host "❌ Ошибка при сохранении XML: $_" -ForegroundColor Red + + # Пробуем сохранить в корень C:\ + try { + $savePath = "C:\Inventory_${Computer}_$(Get-Date -Format 'yyyyMMdd_HHmmss').xml" + $Inventory | Export-Clixml -Path $savePath -Depth 5 + Write-Host "✅ Данные сохранены в: $savePath" -ForegroundColor Yellow + } + catch { + Write-Host "❌ Критическая ошибка сохранения: $_" -ForegroundColor Red + } +} + +# Показываем статистику +Write-Host "`n📊 Статистика сбора:" -ForegroundColor Cyan +Write-Host " - Программ установлено: $($Inventory.InstalledSoftware.Count)" -ForegroundColor White +Write-Host " - Сервисов запущено: $($Inventory.Services.Count)" -ForegroundColor White +Write-Host " - Процессов: $($Inventory.Processes.Count)" -ForegroundColor White +Write-Host " - Дисков: $($Inventory.LogicalDisks.Count)" -ForegroundColor White +Write-Host " - Сетевых адаптеров: $($Inventory.NetworkAdapters.Count)" -ForegroundColor White +Write-Host " - USB устройств: $($Inventory.Peripherals.USBDevices.Count)" -ForegroundColor White + Write-Host "`n✅ Готово!" -ForegroundColor Green \ No newline at end of file