New to scripting trying to get a basic one to work - Pull Logged in Users with a Custom Inventory Rule
Good morning all,
This all comes from needing a way to find out if anyone is currently logged. I can do this from the command line with:
query user /server:computername
I would like to just make this a custom inventory rule but apparently this will not run as localuser so I was advised to run it as a script, output it to a log then have a custom inventory rule just read the log.
i can run this process manually on my own PC. First in the CLI I run :
query user > c:\dell\query_user.txt
then from the CLI I run:
So my question is, how do I setup the first part of this to run (query user /server:computername) to run as a script so I can then run a custom inventory rule to read the log?
Community Chosen Answer
Let's do this....
1- Create a BAT file that will run the command output the results into a TXT file, I'm going to named it Query-User.bat
2- Create a new Script (Don't forget to target the computer or use device labels as target, and select your O.S.) and Launch your BAT File Like this:
3- Use a Custom Inventory Rule to read the TXT file and return what's inside:
ShellCommandTextReturn(cmd /c type C:\ProgramData\Quest\Users.txt)
4- Wait for OR Force Inventory on that Computer, and then you should be able to see THIS!
**We have admin, batman and robin currently logged in, robin is the last active user, he logged in one minute after batman**
This is how it looks like from the computer:
Let us know how that goes.