I have below three syntax, that i need to put in single script.
my purpose is that, i want the the below exchange server components state will come to email, as i will put this .ps1 file in schedule task.
i am using remote powershell
==========================
==========
=====
$UserName = 'domain\username'
$Password = 'secret password'
$Credential = New-Object -TypeName System.Management.Automati
on.PSCrede
ntial -ArgumentList $UserName, (ConvertTo-SecureString $Password -asPlaintext -Force)
$session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri "
http://exchangecasarray.contoso.com/powershell" -Credential $Credential -Authentication Kerberos -AllowRedirection
Import-PSSession $session
Set-AdServerSettings -ViewEntireForest $true
==========================
==========
==========
==========
==========
=
second smtp setting
$smtpsettings = @{
To = "administrator@exchangeser
verpro.net
"
From = "exchangeserver@exchangese
rverpro.ne
t"
Subject = "$reportemailsubject - $now"
SmtpServer = "smtp.exchangeserverpro.ne
t"
}
==========================
==========
==========
====
output in email
Get-ExchangeServer | Get-ServerComponentState | ft
Please suggest, my purpose is to set this whole joined script in task scheudler and result will come on email.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.