First we need to get and export all shared folders.
Get-SmbShare | select name, path |Export-Csv "C:\smbsharelist.csv" -NoTypeInformation -Encoding UTF8
Then we import the csv and run the script below to calculate folder size in GB
Import-Csv -Path "C:\smbsharelist.csv" | ForEach-Object{
$path =$_.Path
$name =$_.Name
$path, "{0} GB" -f ((Get-ChildItem -force $path -Recurse -ErrorAction SilentlyContinue| Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1GB)
} | Set-Content "C:\SizesOfSharedFoldersInGB.csv" -Encoding UTF8
Same script that calculates folder sizes in MB
Import-Csv -Path "C:\smbsharelist.csv" | ForEach-Object{
$path =$_.Path
$name =$_.Name
$path, "{0} MB" -f ((Get-ChildItem -force $path -Recurse -ErrorAction SilentlyContinue| Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1MB)
} | Set-Content "C:\SizesOfSharedFoldersInMB.csv" -Encoding UTF8