Report to show itunes folder size by computer
Hello I am trying to create a custom inventory field on my k1000 box to show the users itunes folder size. I found the text below but I know nothing about how to create any of this nor do I have any experence with sql. Help!.
I did not find any useful tutorials or KB's for helping me create a inventory report for this.
If it's in the kbox you can report on it. This data is not in the appliance by default so you would have to do some work to get it into the kbox. Do you have any ideas of how you would gather this data on the client side?
I found this which seems like a good start. If you put this in a script combined with a custom inventory rule you could get this into the custom inventory data:
@cd /d "%userprofile%/documents"
@For /F "tokens=*" %%a IN ('"dir /s /-c | find "bytes" | find /v "free""') do @Set summaryout=%%a
@Echo %summaryout%
@For /f "tokens=1,2 delims=)" %%a in ("%summaryout%") do @set filesout=%%a&set sizeout=%%b
@Echo %filesout%
@Echo %sizeout%
@Set sizeout=%sizeout:bytes=%
@Echo %sizeout%
@Set sizeout=%sizeout: =%
@Echo Size is :%sizeout%
see this as a reference:
http://www.kace.com/support/kb/index.php?action=artikel&cat=5&id=968&artlang=en
Answers (2)
Sorry for the new answer. I wanted screenshots.
This can be done with a powershell script. Change the $dir on the script below to match the location of the folder. This will output a file to C:\temp\test.txt (change as needed).
$dir= "C:\temp" $colItems = (Get-ChildItem $dir -recurse | Measure-Object -property length -sum) "{0:N2}" -f ($colItems.sum / 1MB) + " MB"|out-file C:\temp\test.txt
Save this script and upload it as a dependency. In the below example I named it script.ps1. Be sure to change "Script File Name" from .sh to .bat.
You can then create a custom inventory rule to read that .txt file. Software>Choose Action> Add New Item. Name it iTunes folder size. Fill in all the necessary info. Enter the text below depending on where you chose the "out-file" to go to. After an inventory of the machine this will now show in the computer inventory.
From there you can use the GUI to create a report since custom fields are unique to your Kbox. After you've used the GUI if you need it modified post what Kace created for you, and I'll help you from there.
Comments:
-
Thanks Got the script working and uploaded got the inventory rule entered. having issues with label / smart label and getting the text to show in inventory. - tjsooley 11 years ago
-
Verify on your test machine that it outputted a .txt file to the path you specified.
Make sure after creating the custom inventory that you force an inventory update before it will show.
I'm not sure what you mean by the smart label? Are you wanting a label for machines that have this custom inventory? - dugullett 11 years ago
-
The custom field does not show up in inventory - tjsooley 11 years ago
-
I have the label created and assigned to the custom inventory field and the label assigned to the test system but it does not show up in inventory - tjsooley 11 years ago
-
Ok. You don't need to create labels for this to work. Where is you're "out-file" pointed to in the Powershell script? - dugullett 11 years ago
-
$env:TEMP\test.txt - tjsooley 11 years ago
-
Paste the whole Powershell script you are running.
Did you add a $env variable? If so you need to have $env="C:\temp\test.txt" - dugullett 11 years ago
-
I changed the out file to c:\temp\temp.txt and changed the inventory rule to reflect that. The script runs fine and correctly. The custom inventory rule doesn't show the text in inventory - tjsooley 11 years ago
-
I have to ask.... you did verify that the .txt file exists at C:\temp\temp.txt, and there is data written to it? - dugullett 11 years ago
-
Yes script is working fine. The issue is I cannot get the custom inventory field to work. The script is not the issue - tjsooley 11 years ago
-
When you run "type C:\temp\temp.txt" (without quotes) from a CMD prompt does it return results?
Did you do an inventory on the machine after you created the custom inventory? - dugullett 11 years ago
-
I need help getting the custom inventory field part to work - tjsooley 11 years ago
-
I made a error in the custom inventory field but fixed it. Now it prompts to open the txt file when I force inventory - tjsooley 11 years ago
-
Copy and paste exactly what you have in the field. That way I can test something. - dugullett 11 years ago
So you've already created the custom inventory, and you just need to report it?
Comments:
-
No how do you create a custom inventory for a folder size - tjsooley 11 years ago
-
ShellCommandTextReturn (cmd.exe /c c:\temp\test.txt - tjsooley 11 years ago
-
Earlier you mentioned your out-file was C:\temp\temp.txt. This is referencing C:\temp\test.txt. Is that a typo? I'm also assuming that you have a closing ")" on the end of this?
Also make sure you are including "type" in the command since this will be what's actually reading the file.
ShellCommandTextReturn (cmd.exe /c type C:\temp\test.txt) - dugullett 11 years ago
-
Thanks it works - tjsooley 11 years ago
-
Cool. When you get ready to create a report for it let me know. It should look something like this. The '75497' in this query should match the software ID for your custom inventory. This will be unique to your Kbox.
SELECT M.NAME, IP, USER_LOGGED, (SELECT MACHINE_CUSTOM_INVENTORY.STR_FIELD_VALUE FROM MACHINE_CUSTOM_INVENTORY
WHERE MACHINE_CUSTOM_INVENTORY.ID=M.ID AND MACHINE_CUSTOM_INVENTORY.SOFTWARE_ID=75497) AS 'ITunes Folder Size'
FROM MACHINE M
ORDER BY M.NAME - dugullett 11 years ago