/build/static/layout/Breadcrumb_cap_w.png

Custom Inventory Rule - Profile Size

I'm wanting to get the profile size from every PC. 

The CIR below returns all the 'profiles' but shows 0.00 for the size

ShellCommandTextReturn(powershell -command "$fso = new-object -com Scripting.FileSystemObject; gci -Directory c:\users\| select @{l='Size'; e={$fso.GetFolder($_.FullName).Size}},FullName | sort Size -Descending | ft @{l='Size [MB]'; e={'{0:N2}    ' -f ($_.Size / 1MB)}},FullName")

this PS returns the info I want, but doesn't seem to work in the CIR.  Ive tried to use "ShellCommandTextReturn(powershell.exe "invoke-command –ScriptBlock {" in front of the PS and still no joy. 

$UserFolders = Get-ChildItem -Path 'C:\Users' -Force -Directory
ForEach ( $Folder in $UserFolders ) {
    $FolderSize = ( Get-Childitem -Path $Folder.FullName -Force -Recurse | Measure-Object -Property "Length" -Sum ).Sum /1GB
      [PSCustomObject]@{
        FolderName    = $Folder.BaseName
        FolderPath    = $Folder.FullName
        Size          = $FolderSize
    }
}


0 Comments   [ + ] Show comments

Answers (1)

Posted by: tshupp 1 year ago
3rd Degree Black Belt
0

Check out this blog from awhile back:

Windows Rule:

ShellCommandTextReturn(powershell -Command "& {Get-ChildItem C:\Users -recurse -force -ErrorAction "SilentlyContinue" | Measure-Object -property length -sum -maximum -minimum}")

Example output:

Count : 156707
Average : 
Sum : 100229316154
Maximum : 1033927956
Minimum : 0
Property : length


https://www.itninja.com/blog/view/calculating-user-folder-sizes


Comments:
  • This doesn't give me what I am looking for
    I'm able to get this when I run the powershell code
    employee C:\Users\employee 20
    The link in the response gives a 'Custom Inventory Field' of
    Count : 156707
    Average :
    Sum : 100229316154
    Maximum : 1033927956
    Minimum : 0
    Property : length
    I just want to know each 'user' and the size of the profile
    I'm not sure why it is difficult to get this information from KACE - Leland 1 year ago
 
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