Author Posts

March 14, 2016 at 7:40 am

Hi Guys, i would expect to see the $Greater string published in the sent mail here, however i does not appear

####Import Shell
$SESJA_EX = New-PSSession -ConnectionUri http://eurxhub02/powershell -ConfigurationName microsoft.exchange
Import-PSSession $SESJA_EX


###Get Detail
$greater50CPY = Get-MailboxDatabaseCopyStatus -Server eurxmbs03 | Select mailboxserver, name, replayqueuelength, COPYqueuelength, status | where {$_.copyqueuelength -ge 0}
$greater50RPLY = Get-MailboxDatabaseCopyStatus -Server eurxmbs03 | Select mailboxserver, name, replayqueuelength, COPYqueuelength, status | where {$_.replayqueuelength -ge 0}
$greater = $greater50CPY + $greater50RPLY

##Variables
$smtpServer = "smtp.xxx.com"
$From = "XMBS-Alerts@xxx.com"
$Email = "mark.prior@xxx.com"
$Subject = "EURXMBS03 Message Queues"
$Body = "$Greater"

#Email Content if $greater50 contains a value
if ($greater50CPY) {Send-Mailmessage -smtpServer $smtpServer -from $from -to $Email -subject $subject -priority High -Body $body}
if ($greater50RPLY) {Send-Mailmessage -smtpServer $smtpServer -from $from -to $Email -subject $subject -priority High -Body $body}

March 14, 2016 at 8:27 am

First, $Greater isn't a string in your script. It appears to be a concatenation of two collections of objects. Why not try piping that to Out-String, so that it generates an actual string?

March 14, 2016 at 12:57 pm

your an absolute gent

that worked, many thanks Don