Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

how to capture results and send email

$
0
0

 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.

 

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>