Написал вот тут как то на досуге скрипт PowerShell для получения данных о конфигурации железа установленного на доменных компах и сведения этих данных в таблицу Excel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
Import-Module activedirectory $Excel=New-Object -Com Excel.Application $Book=$Excel.Workbooks.Add() $Book.workSheets.item(3).delete() $Book.WorkSheets.item(2).delete() $Book.WorkSheets.item(1).Name="Computers" $Sheet=$Book.WorkSheets.Item(1) $Sheet.Cells.Item(1,1)="Name" $Sheet.Columns.Item(1).columnWidth=20 $Sheet.Cells.Item(1,2)="Operating system" $Sheet.Columns.Item(2).columnWidth=25 $Sheet.Cells.Item(1,3)="CPU" $Sheet.Columns.Item(3).columnWidth=35 $Sheet.Cells.Item(1,4)="Мemory" $Sheet.Columns.Item(4).columnWidth=13 $Sheet.Cells.Item(1,5)="Motherboard" $Sheet.Columns.Item(5).columnWidth=25 $Sheet.Cells.Item(1,6)="Hard drive" $Sheet.Columns.Item(6).columnWidth=40 $Sheet.Cells.Item(1,7)="Video card" $Sheet.Columns.Item(7).columnWidth=25 $Sheet.Cells.Item(1,8)="Network" $Sheet.Columns.Item(8).columnWidth=45 $Sheet.UsedRange.Interior.ColorIndex=5 $Sheet.UsedRange.Font.ColorIndex=20 $Sheet.UsedRange.Font.Bold=$True $sheet.Rows.Item(1).HorizontalAlignment=3 $Row=2 get-ADcomputer -Filter * | Sort-Object name | Select-Object name | foreach { if ((Test-connection $_.name -count 2 -quiet) -eq "True"){ $Sheet.Cells.Item($Row,1)=$_.name #Система $sys=Get-WmiObject -computername $_.name Win32_OperatingSystem $Sheet.Cells.Item($Row,2)=$sys.caption+"`n"+$sys.csdversion #Процессор $cpu=Get-WmiObject -computername $_.name Win32_Processor $Sheet.Cells.Item($Row,3)=$cpu.name+"`n"+$cpu.caption+"`n"+$cpu.SocketDesignation #Память $ram=Get-WmiObject -computername $_.name Win32_Physicalmemory foreach ($dimm in $ram){$mem=$mem + $dimm.capacity $dimms=$dimms +1} $speed=$ram[0].speed $Sheet.Cells.Item($Row,4)=($mem / 1Gb).tostring("F00")+"GB`n"+$dimms+"`n"+$speed+"Mhz" $mem=0 $dimms=0 #Материнская плата $mb=Get-WmiObject -computername $_.name Win32_BaseBoard $Sheet.Cells.Item($Row,5)=$mb.Manufacturer+"`n"+$mb.Product #Диск $disk="" foreach ($hard in Get-WmiObject -computername $_.name win32_diskdrive){ if ($hard.MediaType.ToLower().StartsWith("fixed")){ $disk=$disk+(($hard.size)/1Gb).tostring("F00")+"GB - "+$hard.model+"`n"}} $Sheet.Cells.Item($Row,6)=$disk.TrimEnd("`n") #Видеокарта $video="" foreach ($card in Get-WmiObject -computername $_.name Win32_videoController){ if ($card.AdapterRAM -gt 0){ $video=$video+$card.name+"`n"+($card.AdapterRAM/1Mb).tostring("F00")+"MB`n"}} $Sheet.Cells.Item($Row,7)=$video.TrimEnd("`n") #Сеть $net="" foreach ($card in Get-WmiObject -computername $_.name Win32_NetworkAdapter -Filter "NetConnectionStatus>0"){ $net=$net+$card.name+"`n"} $Sheet.Cells.Item($Row,8)=$net.TrimEnd("`n") $Row=$Row + 1 }} $Sheet.UsedRange.WrapText=1 $Sheet.Rows.Item(1).AutoFilter() $Sheet.UsedRange.EntireRow.AutoFit() $sheet.UsedRange.Cells.borders.TintAndShade=1 $sheet.UsedRange.VerticalAlignment=2 $Excel.visible=$True #$book.SaveAs("C:comps.xlsx") #$excel.Quit() |