PowerShell Fast Track by Vikas Sukhija

PowerShell Fast Track by Vikas Sukhija

Author:Vikas Sukhija
Language: eng
Format: epub
ISBN: 9781484277591
Publisher: Apress


if ($error)

{

Send-MailMessage -SmtpServer $smtpserver -From $from -To $to -Subject $subject -Body $error[0].ToString()

$error.clear()

}

Listing 7-1Sending Errors via Email

Listing 7-1 is missing one important thing. It just sends the last error, but what if you want to send the full error, which is actually an array and send-mailmessage is not able to send it effectively? You can utilize the Send-Email function in Listing 7-2, which is also part of the vsadmin module that was shared in the modules chapter.function Send-Email

{

[CmdletBinding()]

param

(

[Parameter(Mandatory = $true)]

$From,

[Parameter(Mandatory = $true)]

[array]$To,

[array]$bcc,

[array]$cc,

$body,

$subject,

$attachment,

[Parameter(Mandatory = $true)]

$smtpserver

)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.