Been a long while inbetween posts - had some study (MS Private Cloud) and been a bit busy with work. But - here is some additional information around using MDT Monitoring with Configuration Manager.
Part one works fine, until the machine is restarted, then the monitoring will effectively halt.
What I wanted to do, is instead of having an additional Task Sequence step after every reboot, have a task that will run on system startup. That way every reboot will restart the monitoring.
My ideal situation was as below :
- use startnet.cmd in winpe to start the monitoring
- use an async command in the unattend.xml to run schtasks to create a scheduled task
- use task sequence step to clean up the scheduled task
Firstly, no matter what I attempted I could not get the monitoring script to run (and function as expected) running from WinPE using startnet.cmd. The script would start, the logging would identify that a step had changed, but the webservice would not fire an event. Now, normally i would work around this and modify the monitoring script to just call the event service with the relevant parameters. BUT - I wanted this to be as much 'out of the box' as possible, no super tweaks or hacks to how the MDT monitoring works.
So instead, I remained with a TS step that runs initially to start the monitoring (As per part 1). This works like a charm.
The second issue I had was actually setting up a scheduled task.
I tried using setupcomplete.cmd - but what I didnt know was that this gets created with a commandline to run the OSD TS. So my change would continuously get overwritten. (But hey, at least I learnt something!)
Secondly i tried adding the relevant command to unattend.xml. However, this would never create the scheduled task. Unsure why exactly, and to be honest I didnt trouble myself too much over it. (PS If anyone has gotten this to work, certainly let me know via the comments!)
So, what else? Well I went with the tried and true TS step. I added an additional step after the Setup Windows and Config Mgr step in my task sequence, that would run the below script to set up the task :
Set objFSO = CreateObject("Scripting.FileSystemObject") Set WshShell = CreateObject("Wscript.Shell") if not objFSO.FolderExists("C:\Windows\Setup\Scripts") then objFSO.CreateFolder "C:\Windows\Setup\Scripts" end if path = objFSO.GetParentFolderName(Wscript.ScriptFullName) objFSO.COpyFile path &"\*.*", "C:\Windows\Setup\Scripts\" , TRUE strTaskName = "Monitor" strCommandLine = "C:\Windows\Setup\Scripts\ZTIMonitor.wsf" wshShell.Run "schtasks /create /tn " & strTaskName & " /tr " & strCommandLine & " /sc onstart /RU SYSTEM" , 1 ,TRUE WshShell.Run "cmd /c " & """START wscript C:\Windows\Setup\Scripts\ZTIMonitor.wsf""" ,1I DO realise that I was a little over zealous with the script copying (really only need ZTIGather, ZTIUtility, ZTIDataAccess and the ZTIMonitor script created in part one) You can also add a line in there to re-enable the DaRT remote control executable as well, to fire up your remote control again.
This set up a scheduled task, on system startup to run the ZTIMonitor.
Elegant? Not at all.
Functional? Yeah, pretty much!
The last thing remaining is to remove the "Monitor" Scheduled task at the end of the TS. Another TS Step (run command line) will do this.
Just to spell it out further here, im not giving anyone a complete end to end solution here - its more showing you what I have done, and giving people some ideas that perhaps they might not have thought of on their own. Think of it as us collaborating on an idea :)
So in conclusion I got the MDT monitoring system to work with a Config Mgr task sequence, with 3 extra TS Steps. I'm happy about that. Now next plan, is to actually make it useful!
Future posts will describe my attempts to use this monitoring service to write events to a DB and monitor using a simple ASP.NET page.