Remote Command using WMI via Commandline

Description

The script will run a command on a remote system using wmic.exe.

Overview

This script leverages the Windows Management Instrumentation Commandline utility or wmic to run a command on a remote system using either impersonation of the current user or explicit credentials.

WMI is an administration feature that provides a uniform environment to access Windows system components. The WMI service enables both local and remote access with the latter leveraging the Distributed Component Object Model (DCOM). Remote WMI over DCOM operates using port 135.

Arguments

Parameter Type Description
Target string The IP address or hostname of the system to run the command.
Username string The local or domain username to authenticate with.
Password string The password for the specified user.
Command string The command to run on the target system.

Dependencies

  • None

Employment Considerations

  • Impersonation requires that the current user have access to the remote system.
  • This script throws one error if successful. Not entirely sure why.
  • You will not receive any output from the executed command using this mechanism.

Example Text Output

Example of successful execution.

Executing (Win32_Process)->Create()

Method execution successful.

Out Parameters:
instance of __PARAMETERS
{
	ProcessId = 5116;
	ReturnValue = 0;
};
Scroll to Top