Book now with code EOY2025
TechJunky wrote: » Use VB and WMI to pull the information. Download the following tools to help you with coding. Scriptomatic2 HTA_Helpomatic Those should give you the scripts your wanting.
astorrs wrote: » Have a look at some examples here for querying that information:Computer Hardware Scripts - VBScript samples
$ErrorActionPreference = "SilentlyContinue" #### Spreadsheet Location $strPath = "C:\Scripts\SERVERINFO\serverinfo.xls" $onerror = "SilentlyContinue" $a = New-Object -comobject Excel.Application $a.Visible = $True $b = $a.Workbooks.Add() $c = $b.Worksheets.Item(1) $c.Cells.Item(1,1) = "Machine Name" $c.Cells.Item(1,2) = "OS Running" $c.Cells.Item(1,3) = "Domain Role" $c.Cells.Item(1,4) = "Total Physical Memory" $c.Cells.Item(1,5) = "Total Free Physical Memory" $c.Cells.Item(1,6) = "Total Virtual Memory" $c.Cells.Item(1,7) = "Total Free Virtual Memory" $c.Cells.Item(1,[IMG]https://us.v-cdn.net/6030959/uploads/images/smilies/icon_cool.gif[/IMG] = "Last Boot Time" $c.Cells.Item(1,9) = "Bios Version" $c.Cells.Item(1,10) = "CPU Info" $c.Cells.Item(1,11) = "Disk Info" $d = $c.UsedRange $d.Interior.ColorIndex = 19 $d.Font.ColorIndex = 11 $d.Font.Bold = $True $d.EntireColumn.AutoFit() $intRow = 2 $cred = Get-Credential ### For Use Later with Quest AD Cmdlets installed ### get-QADcomputer | format-table -hidetableheaders -property Name >> C:\Scripts\computers.txt $computers = Get-Content "C:\scripts\computers.txt" foreach ($computer in $computers) { #### Set Variables $user = $env:USERNAME #### Win32 class short name assignment - add -credential $cred where needed TRY { $OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computer $Bios = Get-WmiObject -Class Win32_BIOS -ComputerName $computer $CS = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer $CPU = Get-WmiObject -Class Win32_Processor -ComputerName $computer $drives = Get-WmiObject -ComputerName $computer Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} #### Set Variable information with short name $OSRunning = $OS.caption + " " + $OS.OSArchitecture + " SP " + $OS.ServicePackMajorVersion $DomainRole = $CS.DomainRole $TotalAvailMemory = $OS.totalvisiblememorysize/1kb $TotalVirtualMemory = $OS.totalvirtualmemorysize/1kb $TotalFreeMemory = $OS.FreePhysicalMemory/1kb $TotalFreeVirtualMemory = $OS.FreeVirtualMemory/1kb $TotalMem = "{0:N2}" -f $TotalAvailMemory $TotalVirt = "{0:N2}" -f $TotalVirtualMemory $FreeMem = "{0:N2}" -f $TotalFreeMemory $FreeVirtMem = "{0:N2}" -f $TotalFreeVirtualMemory $date = Get-Date $uptime = $OS.ConvertToDateTime($OS.lastbootuptime) $BiosVersion = $Bios.Manufacturer + " " + $Bios.SMBIOSBIOSVERSION + " " + $Bios.ConvertToDateTime($Bios.Releasedate) $CPUInfo = $CPU.Name + " & has " + $CPU.NumberOfCores + " Cores & the FSB is " + $CPU.ExtClock + " Mhz" $CPULOAD = $CPU.LoadPercentage if (($DomainRole -eq "0") -or ($DomainRole -eq "1")) { $Role = "Work Station" } elseif (($DomainRole -eq "2") -or ($DomainRole -eq "3")) { $Role = "Member Server" } elseif (($DomainRole -eq "4") -or ($DomainRole -eq "5")) { $Role = "Domain Controller" } else { $Role = "Unknown" } } CATCH { $pcnotfound = "true" } #### Pump Data to Excel if ($pcnotfound -eq "true") { $c.Cells.Item($intRow, 1) = "PC Not Found" } else { $c.Cells.Item($intRow, 1) = $computer $c.Cells.Item($intRow, 2) = $OSRunning $c.Cells.Item($intRow, 3) = $Role $c.Cells.Item($intRow, 4) = "$TotalMem MB" $c.Cells.Item($intRow, 5) = "$FreeMem MB" $c.Cells.Item($intRow, 6) = "$TotalVirt MB" $c.Cells.Item($intRow, 7) = "$FreeVirtMem MB" $c.Cells.Item($intRow, [IMG]https://us.v-cdn.net/6030959/uploads/images/smilies/icon_cool.gif[/IMG] = $uptime $c.Cells.Item($intRow, 9) = $BiosVersion $c.Cells.Item($intRow, 10) = $CPUInfo $driveStr = "" foreach($drive in $drives) { $size1 = $drive.size / 1GB $size = "{0:N2}" -f $size1 $free1 = $drive.freespace / 1GB $free = "{0:N2}" -f $free1 $freea = $free1 / $size1 * 100 $freeb = "{0:N2}" -f $freea $ID = $drive.DeviceID $driveStr += "$ID = Total Space: $size GB / Free Space: $free GB / Free (Percent): $freeb % ` " } $c.Cells.Item($intRow, 11) = $driveStr } $d.EntireColumn.AutoFit() $intRow = $intRow + 1 $pcnotfound = "false" } IF(Test-Path $strPath) { Remove-Item $strPath $a.ActiveWorkbook.SaveAs($strPath) } ELSE { $a.ActiveWorkbook.SaveAs($strPath) }
xmalachi wrote: » You could also use PSTools from MS to get this type of information.
forkvoid wrote: » Could also use Spiceworks, or WMI Asset Logger. No scripting necessary, and does the job and more.
Pash wrote: » You are welcome to use the Pshell script i did in this thread. It probably needs a little more work but it does the job. Let us know if you need anything else added. Pash
mikedisd2 wrote: » You wrote that script? Last week I was feeling clever because I discovered how to use "$cred = Get-Credential".
Use code EOY2025 to receive $250 off your 2025 certification boot camp!