I need help on scripting a report for the K1000 that for each machine pulls all Users that are set as Local Administrators on each PC.
I have a script that somewhat does the job, but I need it tweaked a little bit to where it can omit certain entries like "Administrator", "Domain Name\PC-Techs" and "Domain Name\Domain Admins". These are common on each machine and I don't need that information. Any help would be appreciated! Here is a copy of the script that I currently have....
SELECT MACHINE.NAME AS SYSTEM_NAME, (SELECT MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE FROM MACHINE_CUSTOM_INVENTORY WHERE MACHINE_CUSTOM_INVENTORY.ID=MACHINE.ID AND MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID=6842) AS MACHINE_CUSTOM_INVENTORY_0_6842, (SELECT MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE FROM MACHINE_CUSTOM_INVENTORY WHERE MACHINE_CUSTOM_INVENTORY.ID=MACHINE.ID AND MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID=6843) AS MACHINE_CUSTOM_INVENTORY_0_6843, MACHINE.IP, OS_NAME FROM MACHINE ORDER BY SYSTEM_NAME, INET_ATON(IP)
Answers (4)
I saved that sheet so when I run my weekly report it takes me 2 minutes to take it from the kbox custom inventory string I acquired to readable data in a excel spreadsheet.
I use ShellCommandTextReturn(cmd.exe /c net.exe localgroup administrators) for my custom inventory
it looks like this under the machine:
the raw csv looks like this, I cut and paste that into my saved macro enabled spread sheet.
after the 1st macro
after the 2nd macro
sorted and deleted ok machines, save as another excel name that is non macro enabled.
Comments:
-
Hello Smal.Tmcc I am interested in doing your method. Are you able to provide me the configured Macro Excel sheet this way i can try it out on my report.
Thanks - cdam 3 years ago
Local Administrators on Networked Computers
(without have to use a macro to clean up report)
Setup Customer Inventory
This may already be setup on your system.
Under Inventory,Software, Search for Local Administrator
Verify this Custom Inventory Rule is:
ShellCommandTextReturn(net localgroup Administrators)
If not, then set it up as described below:
Inventory, Software, Choose Action, New
Name: Local Administrators
Select Supported Operating System (to select more than one, hold down the CTRL key- those selected will be highlight in blue.)
Custom Inventory Rule
ShellCommandTextReturn(netlocalgroup Administrators)
After all computers are inventoried by this custom inventory, then thetwo sql report below will a give you the information you required.
SQL Report 1: (Detailed Report)
SELECT MACHINE.IP, MACHINE.USER_NAME, MACHINE.NAME AS SYSTEM_NAME, (SELECT MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE FROM MACHINE_CUSTOM_INVENTORY WHERE MACHINE_CUSTOM_INVENTORY.ID=MACHINE.ID AND MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID=8124) AS MACHINE_CUSTOM_INVENTORY_0_8124 FROM MACHINE WHERE ((( exists (select 1 from MACHINE_CUSTOM_INVENTORY where MACHINE.ID = MACHINE_CUSTOM_INVENTORY.ID and MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID = 8124 and MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE like CONCAT('%', MACHINE.USER, '%'))) )) ORDER BY INET_ATON(ifnull(IP,0))
SQL Report 2: (User Name only Report)
SELECT MACHINE.IP, MACHINE.USER_NAME, MACHINE.NAME AS SYSTEM_NAME,
date_format(LAST_SYNC, '%m/%d/%y') as Last_Date_Sync,
date_format(MACHINE.MODIFIED, '%m/%d/%y') as Last_Date_Modified
FROM MACHINE WHERE ((( exists (select 1 from MACHINE_CUSTOM_INVENTORY where MACHINE.ID = MACHINE_CUSTOM_INVENTORY.ID and MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID = 8124 and MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE like CONCAT('%', MACHINE.USER, '%'))) )) ORDER BY INET_ATON(ifnull(IP,0))