Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Collect Computer System and BIOS Information Using PowerShell

This PowerShell script is designed to gather detailed information about a list of computers, including their manufacturer, model, and BIOS serial number. The information is then exported to a CSV file for easy reference. This script is particularly useful for IT administrators who need to inventory hardware details across multiple machines in a network.


The script reads a list of computer names from a text file (computers.txt), queries each computer using WMI (Windows Management Instrumentation) to gather the necessary details, and then outputs this information into a CSV file (devices.csv). This CSV file can be used for further analysis, reporting, or record-keeping.


Examples:


1. Prepare the Computers List:



  • Create a text file named computers.txt with the names of the computers you want to query, one per line. For example:
     PC1
    PC2
    PC3


2. PowerShell Script Explanation:



  • The script starts by reading the computer names from computers.txt.

  • It then initializes an empty array $devices to store the collected information.

  • For each computer, it retrieves the computer system information and BIOS details using the Get-WmiObject cmdlet.

  • The results are stored in a custom PowerShell object, which is added to the $devices array.

  • Finally, the script exports the collected data to a CSV file named devices.csv.


3. Executing the Script:



  • Open PowerShell with administrative privileges.

  • Navigate to the directory containing the script and the computers.txt file.

  • Run the script:
     .\Get-DeviceInfo.ps1

  • After execution, check the directory for the devices.csv file containing the collected information.


Script Code:


$computers = Get-Content -Path "computers.txt"
$devices = @()

foreach ($computer in $computers) {
$info = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer
$bios = Get-WmiObject -Class Win32_BIOS -ComputerName $computer

$devices += [PSCustomObject]@{
Manufacturer = $info.Manufacturer
Model = $info.Model
SerialNumber = $bios.SerialNumber
}
}

$devices | Export-Csv -Path "devices.csv" -NoTypeInformation

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.