To get the size of a folder using PowerShell we can make use of the combination of Measure-Object cmdlet from Microsoft.PowerShell.Utility module and Get-ChildItem command from the Microsoft.PowerShell.Management module.
Let's see the steps by breaking the one-liner first.
Step 1: We get all the child elements using Get-ChildItem
Get-ChildItem -Recurse -File -Force 'path/to/folder'
Step 2: Get the Size of Individual files using Measure-Object
Measure-Object -Property Length -Sum'
Step 3: Finally take a Sum of each file/object.
-
Example:
(Get-ChildItem -Recurse -File -Force 'data-folder' | Measure-Object -Property Length -Sum).Sum

References:
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!