/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Create a custom inventory rule for a folder inside a users folder

10/29/2020 200 views

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!

0 Comments   [ + ] Show comments

Comments



Community Chosen Answer

1

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.

Answered 10/30/2020 by: Nico_K
Red Belt

All Answers

0

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 NameUsernameIDStateType
services
0
DISK
>consolejdoe1Active

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))



Answered 10/30/2020 by: JordanNolan
9th Degree Black Belt

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ