Try something like this
$dsName = 'Datastore_1'$folderName = 'My_VM'
$ds = Get-Datastore -Name $dsName
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root '\' | Out-Null
$size = Get-ChildItem -Path "DS:\$folderName" -Recurse | Measure-Object -Property Length -Sum | select -ExpandProperty Sum
$ds | Select @{N='Datastore';E={$ds.Name}},
@{N='Folder';E={$folderName}},
@{N='SizeGB';E={[math]::Round($size/1GB,1)}}
Remove-PSDrive -Name DS -Confirm:$false