Wmi tool connects to the Windows Management Instrumentation service on a remote system and lets you run WQL queries, get and delete objects, invoke methods on classes and instances, execute commands, explore the namespace and class hierarchy, and back up or restore the WMI repository.
Subcommands
| Command | Description |
|---|---|
| query | Execute a WMI query |
| get | Get an object by WMI path |
| invoke | Invoke a method on a class or object |
| exec | Execute a command line on a remote system |
| lsns | List namespaces within a namespace |
| lsclass | List classes within a namespace |
| lsprop | List the properties of a class or object |
| lsmethod | List the methods of a class or object |
| backup | Back up the WMI repository |
| restore | Restore the WMI repository |
| delete | Delete a WMI object |
For help on any subcommand, run
Wmi <subcommand> -h.Common options
AllWmi subcommands share these options:
Authentication (credentials)
Authentication (credentials)
Authentication (Kerberos)
Authentication (Kerberos)
query
Executes a WQL (WMI Query Language) query against a remote system and prints the results.Parameters
Parameters
Options
Options
WMI namespace to query.
Number of results to fetch at a time.
Locale for the query.
Filter by qualifiers. Each entry is a qualifier name or
name=value pair.WMI object fields to display in the output.
Output format:
Freeform, Raw, Table, List, Csv, Tsv, Json.Examples
get
Retrieves a specific WMI object by its path, relative to the namespace.Because the command-line parser strips double quotes, use single quotes to delimit strings within paths. Single quotes are automatically converted to double quotes before the request is sent to WMI.
Parameters
Parameters
Examples
invoke
Invokes a method on a WMI class or instance. You can target a specific instance by path or use a WQL query to select multiple objects. To pass an array argument, enclose the elements in[ and ], space-separated:
Parameters
Parameters
Examples
exec
Executes a command line on a remote system usingWin32_Process.Create. By default, the command is wrapped in cmd /q /c and STDOUT/STDERR are captured to a temporary file in C:\Windows\Temp, which is retrieved periodically and printed to your local console.
The command polls for process completion and output using Win32_ProcessTrace. Press Ctrl+C to terminate the remote process.
To disable output capture or cmd /q /c wrapping, use -CaptureOutput:off or -CmdCall:off.
Parameters
Parameters
Options
Options
Redirect STDOUT and STDERR to a file and stream the output locally. Requires
-CmdCall.Prepend
cmd /q /c to the command.Wait for the command to complete before returning.
Polling interval for checking output and process exit. Specify as a number followed by
ms, s, m, or h.Working directory for the new process.
Environment variables in
NAME=value format, comma-separated.Encrypt RPC messages.
Examples
lsns
Lists the WMI namespaces within a given namespace.Parameters
Parameters
Name of the server to connect to.
lsclass
Lists the classes within a WMI namespace.Parameters
Parameters
Name of the server to connect to.
Options
Options
Namespace to list classes within.
Number of results to fetch at a time.
Filter by qualifiers.
Fields to display. Available:
RelativePath, Name, BaseClassName, ObjectFlags, ObjectType, ClassPartBytes, HasMethodPart, NdValueTableLength, ValueTableLength.lsprop
Lists the properties of a WMI class or object. You may specify multiple object paths. Use-WithQualifiers to filter properties. A qualifier name alone matches if the qualifier is present with a non-false value. A name=value pair performs a case-insensitive string comparison.
Parameters
Parameters
Options
Options
Examples
lsmethod
Lists the methods of a WMI class or object. You may specify multiple object paths. Use-WithQualifiers to filter methods. A name=value pair performs a case-insensitive string comparison.
Parameters
Parameters
Options
Options
WMI namespace.
Filter by qualifiers.
Continue on error.
Fields to display. Available:
Name, Signature, Flags, ClassOfOrigin, IsStatic, IsReadOnly, ShortDescription, FullDescription, QualifiersText, PrivilegesText, Subtype, SubtypeCode, Id, IsInputParameter.Examples
backup
Backs up the WMI repository to a file on the remote system.Examples
restore
Restores the WMI repository from a backup file on the remote system.Parameters
Parameters
Options
Options
Force active clients to shut down before restoring.
delete
Deletes a WMI object or a set of objects matching a WQL query.Parameters
Parameters
Examples
Related tools
- Scm — manage services on remote Windows systems
- Smb2Client — file operations over SMB2 (used by
Wmi execto retrieve output)