Thursday, 12 July 2018

Use VBS to remote execute powershell on a device (even if remote powershell is disabled)

Sometimes you will want to execute some powershell script on a machine , but most IT systems now block remote powershell as its to big a security risk. Also the normal IPC$ are also often disabled which stops our old favourite PSEXEC from working.

I found this VBS WMI call does however seem to work in this circumatnaces. It basically lets you do a remote call to powershell.exe and pipe a path to the powershell PS1 file you want to execute.

Eg.

Strcomputername = "remote computer name"
ScommandLine = "powershell.exe C:\temp\myscript.ps1"

set objWMIService = GetObject("winmgmts:{impersonationlevel=impersonate}!\\ & StrComputername & "\root\CIMV2:Win32_Process)

oError = ObjWMIService.Create(ScommandLine, null, null, iProcessID)


No comments:

Post a comment