How can I capture the output of the write-host to a variable then send that info to an email for someone
$year = get-date -f "yyyy"
$month = get-date -f "MM"
$day = get-date -f "dd"
Get-Childitem -Path 'c:\' | foreach-object {
if(!$_.PSIsContainer -and $_.length -eq 0) {
write-host (“{0} -> {1}” -f $_.FullName, $_.Length)
}
} I want to include the date stuff in the Subject of the Email...
SubJect: Zero Byte files found on $Year -- $Month -- $Day
Thanks.