### Get Help for Get-FolderSize Source: https://github.com/gngrninja/psfoldersize/blob/master/README.md Retrieves detailed help information for the Get-FolderSize cmdlet. This command provides comprehensive documentation on how to use the cmdlet, its parameters, and examples. ```powershell Get-Help Get-FolderSize -Detailed ``` -------------------------------- ### Install PSFolderSize Module Source: https://context7.com/gngrninja/psfoldersize/llms.txt Demonstrates how to install the PSFolderSize module from the PowerShell Gallery or import it from a local path. It also shows how to verify the installation and access help for the Get-FolderSize cmdlet. ```powershell # Install from PowerShell Gallery Install-Module PSFolderSize # Or import from local path Import-Module .\PSFolderSize\PSFolderSize.psd1 # Verify installation and get help Get-Help Get-FolderSize -Detailed ``` -------------------------------- ### Install PSFolderSize Module Source: https://github.com/gngrninja/psfoldersize/blob/master/README.md Installs the PSFolderSize module from the PowerShell Gallery. This is the recommended method for easy installation and updates. ```powershell Install-Module PSFolderSize ``` -------------------------------- ### Get Folder Sizes with Get-FolderSize Source: https://context7.com/gngrninja/psfoldersize/llms.txt Shows basic usage of the Get-FolderSize cmdlet to retrieve folder sizes in the current directory and a specified base path. It illustrates how to format the output as a table and how to get the size of a specific folder by name. ```powershell # Basic usage - get folder sizes in current directory Get-FolderSize | Format-Table -AutoSize # Specify a base path to analyze Get-FolderSize -BasePath 'C:\Program Files' | Format-Table -AutoSize # Get size of a specific folder by name Get-FolderSize -BasePath 'C:\Program Files' -FolderName 'Adobe' ``` -------------------------------- ### Get Folder Sizes with File Counts Source: https://context7.com/gngrninja/psfoldersize/llms.txt Shows how to use the -AddFileTotals parameter with Get-FolderSize to include the number of files within each folder. Note that this feature can impact performance. ```powershell # Get folder sizes with file counts $results = Get-FolderSize -BasePath 'C:\Projects' -AddFileTotals $results | Format-List * ``` -------------------------------- ### Get Folder Sizes with Grand Totals Source: https://context7.com/gngrninja/psfoldersize/llms.txt Illustrates how to use the -AddTotal switch with Get-FolderSize to include a summary row showing the total size of all analyzed folders. This provides an aggregate view of disk space usage. ```powershell # Get folder sizes with grand total Get-FolderSize -BasePath 'C:\Users\Admin' -AddTotal | Format-Table -AutoSize ``` -------------------------------- ### Get Folder Size (PowerShell) Source: https://github.com/gngrninja/psfoldersize/blob/master/docs/reference/functions/Get-FolderSize.md Retrieves the size of folders in MB and GB. Supports specifying base paths, omitting folders, and adding total counts or file counts. Output can be formatted in various ways. ```powershell Get-FolderSize | Format-Table -AutoSize ``` ```powershell Get-FolderSize -BasePath 'C:\Program Files' ``` ```powershell Get-FolderSize -BasePath 'C:\Program Files' -FolderName IIS ``` ```powershell $getFolderSize = Get-FolderSize $getFolderSize | Format-Table -AutoSize ``` ```powershell $getFolderSize = Get-FolderSize -Output csv -OutputPath ~\Desktop $getFolderSize ``` ```powershell Sort by size descending $getFolderSize = Get-FolderSize | Sort-Object SizeBytes -Descending $getFolderSize ``` ```powershell Omit folder(s) from being included Get-FolderSize.ps1 -OmitFolders 'C:\Temp','C:\Windows' ``` ```powershell Add file counts for each folder Note: This will slow down the execution of the script by around 30% $results = Get-FolderSize -AddFileTotal PS /Users/ninja/Documents/repos/PSFolderSize\> $results[0] | Format-List * ``` -------------------------------- ### Filter Folders Larger Than 1GB Source: https://context7.com/gngrninja/psfoldersize/llms.txt This example demonstrates how to use PSFolderSize with the Where-Object cmdlet to find and display folders exceeding a specified size threshold (1GB). The results are then sorted by size in descending order and formatted as a table. ```powershell # Find folders larger than 1GB Get-FolderSize -BasePath 'C:\' | Where-Object { $_.SizeGB -gt 1 } | Sort-Object SizeBytes -Descending | Format-Table FolderName, SizeGB -AutoSize ``` -------------------------------- ### Get File Report by Extension Source: https://context7.com/gngrninja/psfoldersize/llms.txt Reports on files matching specific extensions within a directory structure. Defaults to finding `.exe` and `.msi` files. Can find specific extensions, calculate grand totals, and export to CSV. ```powershell # Find executable and installer files (default extensions) Get-FileReport -BasePath 'C:\Program Files' | Format-Table -AutoSize # Output: # FileName SizeBytes SizeMB SizeGB FullPath # -------- --------- ------ ------ -------- # setup 104857600 100.00 0.10 C:\Program Files\App\setup.exe # installer 52428800 50.00 0.05 C:\Program Files\App\installer.msi # Find specific file extensions Get-FileReport -BasePath 'C:\Logs' -FindExtension @('.log', '.txt') | Format-Table -AutoSize # Output: # FileName SizeBytes SizeMB SizeGB FullPath # -------- --------- ------ ------ -------- # application 1073741824 1024.00 1.00 C:\Logs\application.log # error 536870912 512.00 0.50 C:\Logs\error.log # debug 268435456 256.00 0.25 C:\Logs\debug.txt # Find files with grand total Get-FileReport -BasePath 'C:\Downloads' -FindExtension @('.zip', '.rar') -AddTotal # Output: # FileName SizeBytes SizeMB SizeGB # -------- --------- ------ ------ # archive1 2147483648 2048.00 2.00 # backup 1073741824 1024.00 1.00 # GrandTotal for [C:\Downloads] 3221225472 3072.00 3.00 # Export file report to CSV Get-FileReport -BasePath 'C:\' -FindExtension @('.exe') -Output csv -OutputFile 'C:\Reports\executables.csv' ``` -------------------------------- ### Get Folder Size using Robocopy (Windows) Source: https://context7.com/gngrninja/psfoldersize/llms.txt Calculates folder size using Robocopy for potentially faster results on Windows systems. Requires the `-UseRobo` switch. Outputs folder name, size in bytes, MB, and GB. ```powershell # Use Robocopy for size calculation (Windows only) Get-FolderSize -BasePath 'D:\LargeDataSet' -UseRobo | Format-Table -AutoSize # Output: # FolderName SizeBytes SizeMB SizeGB # ---------- --------- ------ ------ # Archive 107374182400 102400.00 100.00 # Backups 53687091200 51200.00 50.00 # Logs 10737418240 10240.00 10.00 ``` -------------------------------- ### PSFolderSize Parameters Source: https://github.com/gngrninja/psfoldersize/blob/master/docs/reference/functions/Get-FolderSize.md This section details the various parameters available for the PSFolderSize module, including their types, default values, and descriptions. ```APIDOC ## PSFolderSize Module Parameters ### -AddFileTotals This parameter allows you to add file totals to the results. Note: This will reduce performance of the script by around 30%! - **Type**: SwitchParameter - **Required**: False - **Default value**: False ### -UseRobo {{ Fill UseRobo Description }} - **Type**: SwitchParameter - **Required**: False - **Default value**: False ### -Output Use this option to output the results. Valid options are csv, xml, or json. - **Type**: String - **Required**: False - **Default value**: None - **Valid options**: csv, xml, json ### -OutputPath Specify the path you want to use when outputting the results as a csv, xml, or json file. Do not include a trailing slash. Defaults to the current location. - **Type**: String - **Required**: False - **Default value**: (Get-Location) - **Example**: C:\users\you\Desktop ### -OutputSort This allows you to specify what you'd like to sort by for the csv/json/xml output. - **Type**: String - **Required**: False - **Default value**: None - **Valid options**: FolderSize, SizeBytes ### -OutputFile This allows you to specify the path and file name you'd like for output. - **Type**: String - **Required**: False - **Default value**: [string]::Empty - **Example**: C:\users\you\desktop\output.csv ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ``` -------------------------------- ### Sort Folder Sizes with Get-FolderSize Source: https://context7.com/gngrninja/psfoldersize/llms.txt Demonstrates how to sort the results of Get-FolderSize by size in descending order and select the top N results. This is useful for identifying the largest folders. ```powershell # Sort results by size descending $results = Get-FolderSize -BasePath 'C:\' | Sort-Object SizeBytes -Descending $results | Select-Object -First 5 ``` -------------------------------- ### Omit Folders with Get-FolderSize Source: https://context7.com/gngrninja/psfoldersize/llms.txt Demonstrates how to exclude specific directories from the folder size analysis using the -OmitFolders parameter. This is useful for ignoring system or temporary folders. ```powershell # Omit specific folders from analysis Get-FolderSize -BasePath 'C:\' -OmitFolders 'C:\Windows', 'C:\$Recycle.Bin', 'C:\ProgramData' | Format-Table -AutoSize ``` -------------------------------- ### Scan Folder Size Across Multiple Servers Source: https://context7.com/gngrninja/psfoldersize/llms.txt This script iterates through a list of servers, calculates the folder size for a specified base path on each, and aggregates the results into a CSV report. It handles cases where the path might not be accessible and adds the server name to each result for identification. ```powershell $basePath = 'c$\Users' $resultsArray = [System.Collections.Generic.List[PSObject]]::new() foreach ($server in $servers) { $uncPath = "\\$server\$basePath" Write-Host "Scanning $uncPath..." if (Test-Path -Path $uncPath) { $result = Get-FolderSize -BasePath $uncPath -AddTotal if ($result) { # Add server name as property for identification $result | Add-Member -MemberType NoteProperty -Name "ServerName" -Value $server $resultsArray.Add($result) | Out-Null } } else { Write-Warning "Cannot access path: $uncPath" } } # Export combined results $combined = $resultsArray | ForEach-Object { $_ } $combined | Export-Csv -Path "C:\Reports\multi_server_report.csv" -NoTypeInformation # Display summary $combined | Where-Object { $_.FolderName -like 'GrandTotal*' } | Select-Object ServerName, SizeGB | Format-Table -AutoSize ``` -------------------------------- ### Scan Folder Sizes Across Multiple Servers Source: https://context7.com/gngrninja/psfoldersize/llms.txt Scans folder sizes across multiple remote servers using UNC paths. Requires defining an array of server names and an ArrayList to store results from each server. ```powershell # Create array to store results from all servers [System.Collections.ArrayList]$resultsArray = @() # Define servers to scan $servers = @('SERVER01', 'SERVER02', 'SERVER03') ``` -------------------------------- ### Calculate Total Size of User Profile Folders Source: https://context7.com/gngrninja/psfoldersize/llms.txt This script calculates the total disk space occupied by user profile folders, excluding specific public or default directories. It uses Measure-Object to sum the sizes and then converts the total bytes to gigabytes for display. ```powershell # Calculate total space used by user profile folders $userFolders = Get-FolderSize -BasePath 'C:\Users' -OmitFolders 'C:\Users\Public', 'C:\Users\Default' $totalSize = ($userFolders | Measure-Object -Property SizeBytes -Sum).Sum Write-Host "Total user profile size: $([math]::Round($totalSize / 1GB, 2)) GB" ``` -------------------------------- ### Import PSFolderSize Module Manually Source: https://github.com/gngrninja/psfoldersize/blob/master/README.md Imports the PSFolderSize module manually from a local path. This is useful if you have cloned or downloaded the module files directly. ```powershell Import-Module .\path\to\PSFolderSize.psd1 ``` ```powershell Import-Module .\path\to\FolderModuleFilesAreIn ``` -------------------------------- ### Export Folder Size to XML Source: https://context7.com/gngrninja/psfoldersize/llms.txt Exports folder size calculation results to XML format, useful for enterprise reporting systems. Can auto-generate filenames or use a specified path. ```powershell # Export results to XML Get-FolderSize -BasePath 'C:\Data' -Output xml -OutputPath 'C:\Reports' # Or specify exact output file Get-FolderSize -BasePath 'C:\Data' -OutputFile 'C:\Reports\data_folders.xml' ``` -------------------------------- ### Export Folder Size to CSV Source: https://context7.com/gngrninja/psfoldersize/llms.txt Exports folder size calculation results to a CSV file. Can auto-generate filenames or use a specified path. Supports sorting output by folder name before export. ```powershell # Export results to CSV with auto-generated filename Get-FolderSize -BasePath 'C:\Users' -Output csv -OutputPath 'C:\Reports' # Exported file: C:\Reports\112523_1430.csv # Export to a specific file path Get-FolderSize -BasePath 'C:\Users' -OutputFile 'C:\Reports\user_folders.csv' # Sort output by folder name before exporting Get-FolderSize -BasePath 'C:\Data' -Output csv -OutputPath 'C:\Reports' -OutputSort FolderName # CSV content example: # "FolderName","SizeBytes","SizeKB","SizeMB","SizeGB","FullPath","HostName" # "Documents","1073741824","1048576.00","1024.00","1.00","C:\Users\Admin\Documents","WORKSTATION01" # "Downloads","536870912","524288.00","512.00","0.50","C:\Users\Admin\Downloads","WORKSTATION01" ``` -------------------------------- ### Export Folder Size to JSON Source: https://context7.com/gngrninja/psfoldersize/llms.txt Exports folder size calculation results to JSON format, suitable for web applications or APIs. Can auto-generate filenames or use a specified path. ```powershell # Export results to JSON Get-FolderSize -BasePath 'C:\Projects' -Output json -OutputPath 'C:\Reports' # Or specify exact output file Get-FolderSize -BasePath 'C:\Projects' -OutputFile 'C:\Reports\projects.json' # JSON output example: # [ # { # "FolderName": "WebApp", # "SizeBytes": 52428800, # "SizeKB": 51200.00, # "SizeMB": 50.00, # "SizeGB": 0.05, # "FullPath": "C:\\Projects\\WebApp", # "HostName": "WORKSTATION01" # }, # { # "FolderName": "API", # "SizeBytes": 31457280, # "SizeKB": 30720.00, # "SizeMB": 30.00, # "SizeGB": 0.03, # "FullPath": "C:\\Projects\\API", # "HostName": "WORKSTATION01" # } # ] ``` -------------------------------- ### Find Largest Folder in Each Subdirectory Source: https://context7.com/gngrninja/psfoldersize/llms.txt This advanced usage finds the single largest folder within each immediate subdirectory of a specified path (e.g., 'C:\'). It pipes the output of Get-ChildItem to ForEach-Object, then uses Get-FolderSize and Sort-Object to identify the largest folder in each, finally displaying the results in a formatted table. ```powershell # Find the largest folder in each subdirectory Get-ChildItem -Path 'C:\' -Directory | ForEach-Object { Get-FolderSize -BasePath $_.FullName | Sort-Object SizeBytes -Descending | Select-Object -First 1 } | Format-Table FolderName, SizeGB, FullPath -AutoSize ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.