Getting to know helpful cmdlets
Before we start covering any SQL Server-specific snippets, it's good to identify cmdlets that are frequently used when you are monitoring and logging any activities. The cmdlets described in this section are the ones you will (most likely) frequently use. Remember to use Get-Help
to get the full documentation on syntax, parameter sets, and examples.
The Send-MailMessage cmdlet
Simply stated, the Send-MailMessage
cmdlet allows you to e-mail something from PowerShell, which is a pretty useful action when you are monitoring something and want to get some alerts or reports via e-mail. This is the syntax of Send-MailMessage
from TechNet:
Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String> ] [[-SmtpServer] <String> ] -From <String> [-Attachments <String[]> ] [-Bcc <String[]> ] [-BodyAsHtml] [-Cc <String[]> ] [-Credential <PSCredential> ] [-DeliveryNotificationOption <DeliveryNotificationOptions...