WMI
Connecting to WMI from PowerShell
$username = 'Administrator';
$password = 'MySecurePass';
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;
# Establish a session using DCOM protocol
$Opt = New-CimSessionOption -Protocol DCOM
$Session = New-CimSession -ComputerName 192.168.1.10 -Credential $credential -SessionOption $Opt -ErrorAction Stop1. Remote Process Creation Using WMI
# Define the command to execute remotely
$Command = "powershell.exe -Command Set-Content -Path C:\munrawashere.txt -Value 'This file was created remotely'";
# Execute the command remotely
Invoke-CimMethod -CimSession $Session -ClassName Win32_Process -MethodName Create -Arguments @{
CommandLine = $Command
}2. Creating Services Remotely with WMI
3. Creating Scheduled Tasks Remotely with WMI
4. Installing MSI Packages Through WMI
Last updated