Send PowerShell Email: Send-MailMessage

 

In PowerShell kann über einen einfachen Befehl eine Email versendet werden: "Send-MailMessage". Mit dem Befehl kann das Versenden von Mails außerhalb der Applikation rein mit PowerShell getestet werden:

Send-MailMessage -to mail@domain.tld -Body "test" -SmtpServer "smtp.domain.tld" -subject "test" -from "test@domain.tld"

-to .. ist die Email-Adresse an die das Mail versendet wird "An:"

-body .. ist der Textinhalt der Email

-bodyAsHtml .. HTML Inhalt anstelle von Text im Body verwenden

-subject .. der Betreff

-from .. die Absender-Email-Adresse. Bei bestimmten Mailservern sollte sich diese im Adressbuch befinden, damit der Mailserver die Nachricht annimmt.

-Credential .. Sollte der Email-Server einen Benutzer für das Versenden verlangen, kann mittels -Credential ein Benutzer mitgegeben werden.

-UseSsl .. SSL für die Verbindung verwenden: Secure Sockets Layer 

siehe: docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7.1

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-12-09 from Bernhard | Übersetzung Deutsch |🔔 | Comments:0

PowerShell TCP Listener | PowerShell | PowerShell Log-Files: Logging into a textfile - write to file

Top articles in this section


PowerShell: File attributes: Change date - without any tools.

As an alternative to special programs, the date of a file or folder can also be changed with PowerShell. 


PowerShell Log-Files: Logging into a textfile - write to file

Log files in PowerShell can be created via the Out-File command, via a custom function, or via PowerShell's built-in Transcript.


PowerShell: Prevent screen saver, lock: Move mouse regularly

Alternatively, if you can't change the screen lock settings, you can move the mouse regularly, or have a script move the mouse. Originally published as an AutoIt script, I recreated the script with a few PowerShell lines. Anyone who copies the following commands into a PowerShell session will prevent the computer from locking the screen or starting the screensaver:

Questions / Comments