If you run a command like this it works fine to any remote machine
schtasks.exe /query /s SomePC /U MyAccount /P XXXXX
If you try to let it point back to your own machine you get an error-message
ERROR: User credentials are not allowed on the local machine.
BUT this is actually FALSE!!! I found a workaround though..
You get the same message whether you are pointing by name (with or without domain), a real IP, 127.0.0.1 or “localhost”.
IF you get the crazy idea and add an entry to your \Windows\System32\Drivers\etc\Host. file, that has your pc’s IP and any name, e.g.
1.2.3.4 MyOwnPCAlias.Something.Never.Used
THEN the command works with that IP – but still not with the rest (nor the alias)
schtasks.exe /query /s 1.2.3.4 /U MyAccount /P XXXXX
This trick proves that it is NOT a limitation in the WinRM protocol nor schtasks.exe, but an erroneous error message, as someone prohibited something that actually technically works just fine… (And is useful with other credentials!)
With the trick I guess the program makes a reverse lookup on the IP, and detect it as not the current pc name, and then proceeds processing the call through WinRM and not locally…
The bug and trick goes for both stand-alone machines and machines in a domain. (Only works for real IP not 127.0.0.1 though)
I stumbled upon it inventorying a range of PC’s with an administrative account, and found I was prohibited from querying the running machine with schtasks.exe , and in a desperate attempt I tried an alias. Only to detect that did not work either, but then accidentally executed with the IP again before removing the Hosts entry….
Can you tell me excatly how you named MyOwnPCAlias.Something.Never.Used this part? I’ve tried “SCHOOL00ROOM00PC00.smth.never.used” (SCHOOL00ROOM00PC00 is my pcs name) and “localhost.smth.never.used” but it still gave me the same error. maybe I am doing the “smth.never.used” part wrong?? help pls
thanks
I haven’t tried it for years actually.
But the trick is you can give it any random name in the “Hosts.” file along with your real (LAN) IP. Then (and only then) schtasks can access it by the IP.
(You can then get an “Access Denied”, if the account isn’t allowed to do it, e.g. if the PC does not allow requests from LAN – but that is another matter)
It worked now. Thanks!
also when I do it with the pc name instead of “localhost” it proceeds but waits approximately 5-10 seconds and tells “ERROR: The request is not supported.”. But its not like this when I use “localhost”.
The message “The request is not supported.” seems to be their way to say that they can not recognise/resolve the network name