Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

Scripting with WMI: PowerShell, VBScript, and Remote Access

WMI is Windows’ management infrastructure, while PowerShell and scripting APIs are ways to access it. Learn current CIM query patterns, legacy compatibility, and remote security requirements.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

WMI is a Windows management infrastructure, not a scripting language. Scripts and applications use it to query system information, call management operations, or receive events exposed by WMI providers. For new PowerShell scripts, use CIM cmdlets such as Get-CimInstance; reserve older WMI cmdlets for maintaining Windows PowerShell scripts.

What WMI does

Windows Management Instrumentation (WMI) is Microsoft’s implementation of Web-Based Enterprise Management (WBEM), using the Common Information Model (CIM) to represent managed systems and components. A script or application acts as a consumer: it asks WMI for management information or an operation. WMI connects that request to a provider, which exposes the data and operations for a particular area of Windows. The WMI service and repository help organize and serve that information. Microsoft’s overview of WMI and its WMI architecture documentation describe these roles.

The repository contains class definitions and other static information, while providers often retrieve requested values dynamically. As a result, what you can read or do depends on the provider and the class—not on a universal set of capabilities guaranteed by WMI.

Choose a scripting interface

Approach Best fit Important distinction
PowerShell CIM cmdlets New PowerShell automation Microsoft recommends CIM cmdlets. Get-CimInstance uses WS-Man by default for remote connections; DCOM is also an option, with setup dependent on the environment.
PowerShell WMI cmdlets Understanding or maintaining older Windows PowerShell scripts Get-WmiObject is a legacy cmdlet. Microsoft describes the older WMI cmdlets as deprecated and unavailable in PowerShell 6 and later.
WMI Scripting API VBScript, Visual Basic, VBA, and other languages that support active scripting This is an API for accessing WMI, not WMI itself. Its scripting objects generally are not marked safe for scripts embedded in Internet Explorer HTML pages.

Microsoft’s PowerShell guidance on working with WMI explains the CIM and legacy cmdlet distinction. The WMI Scripting API reference lists supported scripting languages and the legacy Internet Explorer host caveat; that caveat is not a recommendation to deploy scripts in that host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run a local PowerShell query

For a new PowerShell script, query a class with Get-CimInstance. This example requests operating-system instances in the commonly used rootcimv2 namespace and selects a few properties:

Get-CimInstance -Namespace 'rootcimv2' -ClassName Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber

The returned properties depend on the class and provider. To inspect available properties on an instance, you can pipe the result to Get-Member. The cmdlet and class do not guarantee that every system exposes identical values.

Older scripts may instead contain Get-WmiObject. For example, the following is legacy syntax for Windows PowerShell 5.1, not PowerShell 6 or later:

Get-WmiObject -Namespace 'rootcimv2' -Class Win32_OperatingSystem

When updating such a script, check more than the cmdlet name: remote transport, output behavior, and any methods or provider-specific functionality the script relies on may matter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand namespaces, classes, properties, methods, and events

  • Namespace: A logical organization for WMI classes and providers. rootcimv2 is a commonly used namespace, but a class may be elsewhere.
  • Class: Describes a kind of managed object, such as an operating-system instance. A query names the class it wants to retrieve.
  • Property: A value exposed on an instance, such as a version string. Provider support determines which values are available.
  • Method: An operation a provider exposes for a class or instance. Availability and behavior are provider-specific; do not assume every class supports a method.
  • Event: A notification a consumer can subscribe to when a provider supports the relevant event.

WMI consumers can query or enumerate data, invoke provider methods, and subscribe to events. These are distinct uses of the infrastructure: a successful read query does not establish that a method or event subscription is supported.

Query a remote computer

Remote WMI access is not simply a local query with a different computer name. The protocol, target configuration, credentials, namespace permissions, and network rules all affect whether a connection succeeds. Get-CimInstance uses WS-Man by default for remote connections according to Microsoft’s PowerShell material; CIM can also use DCOM. Classic WMI scripting clients use DCOM and need appropriate DCOM security configuration.

Rank #4
Sale
PowerShell for Sysadmins: Workflow Automation Made Easy
  • Book - powershell for sysadmins: workflow automation made easy
  • Language: english
  • Binding: paperback

A basic CIM query can specify a remote computer and credentials:

$credential = Get-Credential
Get-CimInstance -ComputerName 'server01' -Credential $credential -Namespace 'rootcimv2' -ClassName Win32_OperatingSystem

This example uses the cmdlet’s default remote transport, WS-Man. It does not configure the target, open firewall access, grant namespace rights, or guarantee that the account is authorized. Follow the organization’s approved remote-management configuration, grant only the permissions required, and avoid broad firewall exposure. Microsoft’s guidance covers security for WMI scripting clients and emphasizes suitable security settings for local and remote namespace connections.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot failed queries

Diagnose the layer that failed before concluding that a class does not exist. A local success only confirms that the local query worked under its local security and provider conditions.

  • Access denied: Check which account the script is using, its rights on the target, and permissions on the requested namespace. For classic scripting clients, also verify the required DCOM security settings. Administrative rights can be relevant to remote connections, but use the least privilege that meets the requirement.
  • Remote target unavailable or connection times out: Confirm the target name and reachability, then verify that the selected protocol—WS-Man by default for remote Get-CimInstance use, or DCOM if explicitly used—is configured and permitted by the target and network. A transport or firewall problem is not evidence that a WMI class is missing.
  • Class not found or no expected data: Verify the namespace and class name, then check whether the target’s provider exposes that class and the requested properties. Provider availability and returned values can differ by managed object and system configuration.
  • Legacy command fails in a newer PowerShell: Check the PowerShell edition/version. Get-WmiObject belongs to legacy Windows PowerShell scripts and is not available in PowerShell 6 and later; use CIM cmdlets for new work or plan a compatibility-focused migration.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.