Creating a SysInternals PSExec Console Task for OpsMgr 2007
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.
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:
- Save above Vbscript on a location where all OpsMgr Console have access to. (like d:\scripts\startpsexec.vbs)
- Create a new Console Command Line Task
- Give the Task a Name like “Remote Interactive CmdPrompt”
- Target the Task to Windows Server
- 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.
- Save Task
Result:
Comments
Anonymous
January 01, 2003
Hi Pete, Thanks for telling me. Why didn't find your article before ;-) You solved it by creatingediting the Console Task (without the space) directly in the MP XML file. Correct? Regards, Stefan StrangerAnonymous
January 01, 2003
Stefan, I blogged about this UI bug and created how-to with an MP a few months ago.. http://www.systemcenterforum.org/news/remote-interactive-command-prompt-task-mp-for-opsmgr-and-essentials-2007/