Совсем китайская грамота ?
Почитайте какую-нибудь вводную статью :)
$body = gci -force 'E:\BASE\enm*','F:\DATE\enm*' -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$_.fullname, '{0:N2} Gb' -f ($len / 1Gb)
}
$Body = $Body -join "`r`n"
Send-MailMessage -From 'test@test.ru' -To 'test@test.ru', -Subject "enm size" -Body $Body –SmtpServer '10.10.10.10'
Если хочется на экран тоже вывести
gci -force 'E:\BASE\enm*','F:\DATE\enm*' -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$_.fullname, '{0:N2} Gb' -f ($len / 1Gb)
} | Tee-Object -Variable body
$Body = $Body -join "`r`n"
Send-MailMessage -From 'test@test.ru' -To 'test@test.ru', -Subject "enm size" -Body $Body –SmtpServer '10.10.10.10'