Why is string not published in email body

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Mark Prior Mark Prior 6 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36505
    Profile photo of Mark Prior
    Mark Prior
    Participant

    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 = "[email protected]"
    $Email = "[email protected]"
    $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}
    
    #36513
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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?

    #36542
    Profile photo of Mark Prior
    Mark Prior
    Participant

    your an absolute gent

    that worked, many thanks Don

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.