\\ Amazon パソコン・周辺機器 クーポンをチェックしよう!! //

How to Use the PowerShell Get-WmiObject Command | Retrieve System and Hardware Information

目次

What is the Get-WmiObject Command?

Get-WmiObject is a PowerShell cmdlet used to access detailed system and hardware information through Windows Management Instrumentation (WMI) classes. As a PowerShell version of the wmic command, it provides a more flexible and script-friendly way to gather system details, such as CPU, memory, disk drives, and network settings, making it ideal for system administrators and troubleshooting.

Main Uses

  • Retrieve hardware information: Get detailed data on CPU, memory, disk drives, network adapters, and more.
  • Monitor OS and process information: Display information on the running operating system and processes to monitor system health.
  • Script automation with WMI: Create scripts that automatically collect system information using WMI classes.
  • Manage remote systems: Retrieve WMI information from remote computers for remote system management.

How to Use the Get-WmiObject Command

The Get-WmiObject command allows you to query system information based on specified WMI classes. By specifying a class name, you can retrieve detailed hardware and software data.

Basic Syntax

Get-WmiObject -Class <ClassName>
  • ClassName: The WMI class related to the information you want to retrieve, such as Win32_Processor or Win32_OperatingSystem.

Examples

  1. Retrieve CPU information
Get-WmiObject -Class Win32_Processor

This command provides information about the installed CPU, including its name, clock speed, and core count. It’s useful for checking CPU performance and status.

  1. Retrieve memory information
Get-WmiObject -Class Win32_PhysicalMemory

Displays information about the physical memory (RAM) installed on the system, such as capacity, speed, and manufacturer.

  1. Retrieve OS information
Get-WmiObject -Class Win32_OperatingSystem

This command shows details about the operating system in use, including its name, version, and installation date.

  1. Retrieve disk drive information
Get-WmiObject -Class Win32_DiskDrive

Displays the model, capacity, and status of installed disk drives, helping you check the health and size of your drives.

Key Get-WmiObject Classes

Here are some key WMI classes that can be used with Get-WmiObject to retrieve system information:

  1. Win32_Processor
Get-WmiObject -Class Win32_Processor

Provides details on the CPU, such as its name, clock speed, core count, and threads.

  1. Win32_PhysicalMemory
Get-WmiObject -Class Win32_PhysicalMemory

Displays information about physical memory, including capacity and speed.

  1. Win32_OperatingSystem
Get-WmiObject -Class Win32_OperatingSystem

Shows details about the operating system, such as the OS name, version, installation date, and uptime.

  1. Win32_DiskDrive
Get-WmiObject -Class Win32_DiskDrive

Provides information about installed disk drives, such as model, serial number, capacity, and status.

Practical Use Cases for Get-WmiObject

1. Retrieve Full System Overview

Get-WmiObject -Class Win32_ComputerSystem

This command gives an overview of the system, including the model, manufacturer, physical memory, and number of processors.

2. List All Running Processes

Get-WmiObject -Class Win32_Process | Select-Object Name, ProcessId

Displays a list of all running processes with their names and process IDs (PIDs), which is useful for process management and troubleshooting.

3. Retrieve Information from a Remote Computer

Get-WmiObject -Class Win32_OperatingSystem -ComputerName <RemotePCName>

This command retrieves OS information from a remote computer, allowing for remote management and system monitoring.

Important Considerations When Using the Get-WmiObject Command

  • Administrator privileges required: Some queries and operations require administrator privileges. Make sure to run PowerShell as an administrator when needed.
  • Use in PowerShell Core: Get-WmiObject is only available in Windows PowerShell, not PowerShell Core. In PowerShell Core or newer versions, use Get-CimInstance as an alternative.

関連コマンド

Conclusion

The Get-WmiObject cmdlet is a powerful tool for retrieving detailed system and hardware information in Windows. By using WMI classes, you can easily gather data on the CPU, memory, disk drives, and operating system, making it invaluable for system management and troubleshooting. For modern systems or PowerShell Core, consider using Get-CimInstance as an alternative.

Tamaglo

Thank you for reading!

Comments

To comment

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here

目次