Gettting the folder id

New post


1 comment

  • hunnj

    Hi Maneesh,

    I don't use the regular APIs directly that much but do leverage the Box CLI within PowerShell scripts.  You can get the folder size using the standard using the regular Get Folder Informtion:


    The following PowerShell snippet is what I use - it is probably not the most elegant or efficient but works.  My input file is in the following format but for this only needs the FolderID - I just happen to use the csv for other purposes as well.


    Input File:




    Sample Box CLI PowerShell script:
    if($args.count -eq 2)
    Write-Output "Usage: ps .\box-get-users-share-size-report.ps1 inputfile outputfile"

    $box_adminid = "xxxxx" # Box Support ID with appropriate permissions
    $csv = Import-Csv $inputfile -delimiter ","

    $myarray = @()

    $count = 0

    $totalUsers = $csv.Count

    Foreach ($csv in $csv){

    $json = box folders:get $csv.folderid --as-user $box_adminid
    $parsed = $json | ConvertFrom-Json

    $myarray += [PSCustomObject] @{
    login = $csv.login
    folder = $
    size = ($parsed.size/1000000000)

    $count = $count + 1

    Write-Progress -activity "Compiling Box Folder Stats . . ." -status "Scanned: $count of $totalUsers" -PercentComplete (($count / $totalUsers) * 100)

    $myarray | ConvertTo-Csv -NoTypeInformation | Set-Content $outputfile

    Write-Output ""
    Write-Output ""
    Write-Output "Processing complete: "$count" User folders found."
    Write-Output ""


    Hope that helps.



    Comment actions Permalink

Please sign in to leave a comment.