Creating a SysInternals PSExec Console Task for OpsMgr 2007

Creating a SysInternals PSExec Console Task for OpsMgr 2007

  • Comments 2
  • Likes

Pete Zerger wrote an article about creating a Console Task to launch a Remote Interactive CmdPrompt for MOM 2005 using PSExec. A customer asked if this also could be done for OpsMgr 2007, this was not as easy as I thought. It turned out that an extra space is added before the servername where psexec wants to connect if you create a Command Line  Console Task. I don’t know why this extra space is added after saving the Console Task yet.

image image

To solve this issue I created a Vbscript which has the servername as argument and can be used to start psexec from within a vbscript.

‘start startpsexec.vbs

Option Explicit
On error resume next

Dim strServer
strServer = CStr(WScript.Arguments(0))
Set objShell = CreateObject("WScript.Shell")
ObjShell.Run ("%comspec% /C psexec.exe \\" & strServer & " cmd.exe /S, 4, true")

‘End startpsexec.vbs

Prerequisites

  • SysInternals PSTools (these need to be installed on all machines where the OpsMgr Console is being used)
  • Add the PSTools directory to the PATH System variable
  • Startpsexec.vbs script (this vbscript needs to be installed on all machines where the OpsMgr Console is being used)

Steps:

  1. Save above Vbscript on a location where all OpsMgr Console have access to. (like d:\scripts\startpsexec.vbs)
  2. Create a new Console Command Line Task
  3. Give the Task a Name like “Remote Interactive CmdPrompt”
  4. Target the Task to Windows Server
  5. Enter at Application: %WINDIR%\SYSTEM32\cscript.exe
    Enter at Parameters: D:\Scripts\startpsexec.vbs $Target/Property[Type="MicrosoftWindowsLibrary6062780!Microsoft.Windows.Computer"]/DNSName$
    Disable Display output when this task is run.
    image
  6. Save Task

Result:

image

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment