Create a custom inventory rule for a folder inside a users folder
Looking to create a custom inventory rule for .squirrel sql under users account to see which PCs have squirrel installed. I am unable to create a CIR for location at which SQuirrel is installed because they may not be in the same location or name but the .squirrel sql folder is consistent.
DirectoryExists(C:\users\%username%\squirrel sql)
Any help/tips would be great!
Answers (2)
this will not work since the agent runs as SYSTEM and therefore it will not show anything you need.
YOu need to create a batch or powershell script and put it in a readable folder.
Then you can run it via a custom inventory rule.
If the script runs long, you should run it regulary via Scripting and put the results into this folder and read the results with the CIR.
As Nico_K mentioned, the Kace agent does run as the system account, however I do find that the search for User registry settings does search the current logged on user profile. For example we know the system account does not map drives, but the RegistryValueReturn() function returns values from HKCU for the currently logged in user for me. If squirrel sql adds user registry keys you can retrieve those. This example returns a user's mapped P: Drive for me
RegistryValueReturn(HKCU\Network\p, RemotePath, TEXT)
If it does not, you can probably use the ShellCommandTextReturn(command) to search if the folder exists and return a Yes or No value. You can use the query session command and parse it to find the currenly logged in user, then search if a folder exists under that user profile.
query session returns:
Session Name | Username | ID | State | Type |
services | 0 | DISK | ||
>console | jdoe | 1 | Active |
Here is an example of checking if the Desktop folder is present for the currently active user logged in:
for /f "tokens=1-4" %a in ('query session') do @if "%a"==">console" IF EXIST %SYSTEMDRIVE%\Users\%b\Documents (Echo YES) else (Echo No)
So I believe you would be looking for something like:
ShellCommandTextReturn(cmd /c for /f "tokens=1-4" %a in ('query session') do @if "%a"==">console" IF EXIST %SYSTEMDRIVE%\Users\%b\squirrel (Echo YES) else (Echo No))