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 Retrieve System Information via PowerShell

In systems engineering, obtaining detailed system information is crucial for various tasks such as troubleshooting, system audits, and performance monitoring. PowerShell is a powerful tool for gathering this information on Windows systems. This article will guide you on how to retrieve information about the operating system, disk space, processors, and memory using PowerShell.

Examples: Below is a PowerShell script that gathers and displays information about the operating system, disks, processors, and memory:

# Display Operating System Information
Write-Host ""
Write-Host "OS"
$os = Get-WmiObject -Class Win32_OperatingSystem
Write-Host "Sistema Operacional: $($os.Caption)"
Write-Host "Versão: $($os.Version)"
Write-Host "Arquitetura: $($os.OSArchitecture)"
Write-Host ""

# Display Disk Information
Write-Host "Disco"
$disks = Get-WmiObject -Class Win32_LogicalDisk
foreach ($disk in $disks) {
    Write-Host "Disco: $($disk.DeviceID)"
    Write-Host "Espaço Total: $($disk.Size) bytes"
    Write-Host "Espaço Livre: $($disk.FreeSpace) bytes"
}
Write-Host ""

# Display Processor Information
Write-Host "Processadores"
$processors = Get-WmiObject -Class Win32_Processor
foreach ($processor in $processors) {
    Write-Host "Processador: $($processor.Name)"
    Write-Host "Velocidade: $($processor.MaxClockSpeed) MHz"
    Write-Host "Número de Núcleos: $($processor.NumberOfCores)"
}
Write-Host ""

# Display Memory Information
Write-Host "Memória"
$memory = Get-WmiObject -Class Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum
Write-Host "Memória Total: $($memory.Sum) bytes"

This script performs the following tasks:

  1. Operating System Information: It uses the Get-WmiObject cmdlet to query the Win32_OperatingSystem class and retrieve details about the operating system, such as its name, version, and architecture.

  2. Disk Information: It queries the Win32_LogicalDisk class to gather information about each logical disk, including the device ID, total size, and free space available.

  3. Processor Information: It retrieves details about the processors installed on the system by querying the Win32_Processor class. This includes the processor name, maximum clock speed, and the number of cores.

  4. Memory Information: It uses the Win32_PhysicalMemory class to get the total physical memory installed on the system, summing up the capacity of all memory modules.

Running this script in PowerShell will provide a comprehensive overview of the system's hardware and operating system details.

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.