Following this post http://community.kaseya.com/xsp/f/114/t/24138.aspx I am trying to find out if a couple of specific user folders exist on a computer. So I wrote the following procedure:
If checkVar("C:\users\%username%\Desktop") Exists
If checkVar("C:\users\%username%\OneDrive - Bakemark LLC\Desktop) Does not Exist
writeProcedureLogEntry("Desktop folder Exists", "Windows 10", "Halt on Fail")
If checkVar("C:\users\%username%\Documents") Exists
If checkVar("C:\users\%username%\OneDrive - Bakemark LLC\Documents) Does not Exist
writeProcedureLogEntry("Documents folder Exists", "Windows 10", "Halt on Fail")
Then I created a report that filters for those two values. But when I tested this I got results in my report for a machine that I know does not have a C:\users\myusername\Desktop folder, it's in C:\users\myusername\OneDrive - Bakemark LLC\Desktop. I think the problem could be my report using last logged in user as a column because there's a different user on the computer that does have the folder as C:\users\otheruser\Documents and C:\users\otheruser\Desktop. So is there a way to get the report or the log to use the username in the Procedure Log or some other way to approach this?
Hi trevor.okazaki Can you post a screenshot (or xml) of you procedure?
Tried pasting the XML and that was incomprehensible.
I may have found a different approach using a batch file that pulls a reg key and writes a log file but now I have to figure out how to parse the log file so I can get the notification.
For context what I'm trying to do is look at 100 computers and see if our GPO to move their Desktop and Documents folders to the OneDrive folder has happened. So the end result is I want a log of computer/user that's not in compliance. So the procedure writing to the agent at least lets me ID the computer. The batch file creates a log with the registry entries so if I can figure out the parsing then Monitoring can email me when it finds machines out of compliance.
I'm not sure, but I don't think you can use %username% in checkvar like that. You could try using #vAgentConfiguration.currentUser# or #vAgentConfiguration.lastLoginName#.
There are probably a dozen ways to do what you want though too! :D
I would try using an ExecuteShellCommandtoVariable (as user)
shell command to run:
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal
(output will contain path to Documents special folder)
If checkVar #global:cmdresults# contains OneDrive
Then = has OneDrive as doc location
Else = does not have OneDrive as docs location
Thanks myArch-man! I'm going to try that now.
Our current solution for a few users is to run a procedure that drops a bat file onto the computer and runs it. The bat is:
REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" > c:\temp\Win10.txt
which kicks out a nice list of all of the folders into the text file. The downside is it doesn't ID the users or say what computer they're on and in a few instances we have multiple users on a single desktop. So I was going to go digging to see if I could get kaseya to grab and email that file from the selected users.
This will display the full path of the OneDrive folder for the target user:
REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1" /v UserFolder
This will display the "First Last" of the target User:
REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1" /v UserName
I'm working on similar procedure, but instead i use, GetVariable, Registry Value, which returns a much cleaner result. I'll share it when I'm done.