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.
On error resume next
strServer = CStr(WScript.Arguments(0))
Set objShell = CreateObject("WScript.Shell")
ObjShell.Run ("%comspec% /C psexec.exe \\" & strServer & " cmd.exe /S, 4, true")
- 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)
- 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