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:

0 Comments   [ - ] Hide Comments


Please log in to comment

Community Chosen Answer



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.

Answered 04/09/2013 by: dugullett
Red Belt

  • 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.
    • 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?
  • The custom field does not show up in inventory
  • 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
    • Ok. You don't need to create labels for this to work. Where is you're "out-file" pointed to in the Powershell script?
  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
  • $env:TEMP\test.txt
    • 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"
  • 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
    • I have to ask.... you did verify that the .txt file exists at C:\temp\temp.txt, and there is data written to it?
  • Yes script is working fine. The issue is I cannot get the custom inventory field to work. The script is not the issue
    • 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?
  • I need help getting the custom inventory field part to work
  • I made a error in the custom inventory field but fixed it. Now it prompts to open the txt file when I force inventory
    • Copy and paste exactly what you have in the field. That way I can test something.
Please log in to comment
Answer this question or Comment on this question for clarity



So you've already created the custom inventory, and you just need to report it?

Answered 04/09/2013 by: dugullett
Red Belt

  • No how do you create a custom inventory for a folder size
  • ShellCommandTextReturn (cmd.exe /c c:\temp\test.txt
    • 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)
  • Thanks it works
    • 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.

Please log in to comment