powershell: sending e-mail with attachments (using a pipe)
$PSEmailServer = "mailsrv"
Get-ChildItem("c:\temp") |
ForEach {$_.fullname} |
Send-MailMessage -to "x@regele.org" -from "y@regele.org" -subject "hi" -encoding ([System.Text.Encoding]::UTF8)
Get-ChildItem("c:\temp") |
ForEach {$_.fullname} |
Send-MailMessage -to "x@regele.org" -from "y@regele.org" -subject "hi" -encoding ([System.Text.Encoding]::UTF8)
- $PSEMailServer needs to contain the smtp Server
- ForEach ... $_.fullname is required if files are not in current path
Kommentare
Get-Service | Where {$_.Status -eq "Running"} |
Where {$name = $_.name
1 -eq (Get-WmiObject Win32_Service -Filter "Name='$name'" |
where {$_.StartMode -eq "Auto"} |
Measure-Object).Count;
} | FT