Thursday, February 2, 2012

Schtasks Query /TN Tasks over the network

Well here we go, I had to write something about this as once again this is the ultimate in stupidity from our boys at Microsoft.

My goal here was originally to query the time of my server backups across all servers in the data-center.

According to the help provided and by running the command line "schtasks /Query /?" we get the following as one of the available switches:

    /TN   taskname

Notice the ease of "ooh" just type in /TN taskname and voila! So my full command you would think would be:

schtasks /Query /S ServerName /TN  Microsoft-Windows-WindowsBackup



We get a vague "ERROR: The system cannot find the path specified." Say what 0_o????

So here is the part where we spend way too much time trying to find the solution to this STUPID problem.

Taking a guess from the error message I decided to put in the full path after the  /TN switch, I mean Microsoft would not be so idiotic to actually make me type in the entire path for each task just to search it right ??

WRONG! They would..... /facepalm ../wrist ../FAIL

 schtasks /Query /S ServerName /TN \Microsoft\Windows\Backup\Microsoft-Windows-WindowsBackup

TaskName                                 Next Run Time          Status
======================================== ====================== ===============
Microsoft-Windows-WindowsBackup          2/3/2012 5:00:00 AM    Ready

So lets just put that one into the books in my new ever growing IT FAIL library.

Now lets try that on a Linux box:

ssh user@box crontab -l |grep -i TheTask


0_0 /facepalm