Add a function to return folder size in Powershell I am querying a drive for folder name/count/last modified.  However I would also like to add folder size MB.  I have searched/tried a few options but can't get them to work.
The file is also failing due to some paths being over 240char. Is there a workaround for this (eg skipping these folders)?
Grateful for help with a line of code that I would add.  Or any changes to below.
Many thanks.
$FOLDER_ROOT = "K:\Docs\"
$OUTPUT_LOCATION = "C:\Users\me\Documents\Powershell_OUT.txt"
Function DirX($directory)
{
    Remove-Item $OUTPUT_LOCATION

    foreach ($singleDirectory in (Get-ChildItem $directory -Recurse -Directory))
    {
$count = Get-ChildItem $singleDirectory.FullName -File | Measure-Object | %{$_.Count}
$summary = $singleDirectory.FullName+"|"+$count+"|"+$singleDirectory.LastAccessTime
Add-Content $OUTPUT_LOCATION $summary
    }
}
DirX($FOLDER_ROOT)