none
Extract Message set in OOO using powershell

    问题

  • Hi All,

    I have a one-line script in my workflow which checks for AutoReply state set for a user and based on the response take an action.

    If the OutOfOffice is Enabled and Scheduled then i have been asked to get the message set and convert to a html file and to be sent to an email address.

    $OOOtext = Get-MailboxAutoReplyConfiguration -Identity 'SAMAccountName' | Select ExternalMessage

    $OOOtext | Out-File C:\Users\Location\User1.htm

    The above query does not work as it gives me a text ExternalMessage in the file.

    PLease advise how to take it further.


    Justin

    2018年6月13日 10:55

答案

  • Hi Justin,

    Try the following command and check again:

    $OOOtext | Export-Csv C:\Users\Location\User1.html -NoTypeInformation


    Best Regards,
    Niko Cheng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年6月14日 8:58
    版主

全部回复

  • That property is a string.  In your script, you can wrap the string in whatever HTML you want.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Celebrating 20 years of providing Exchange peer support!

    2018年6月13日 18:34
  • Hi Justin,

    Try the following command and check again:

    $OOOtext | Export-Csv C:\Users\Location\User1.html -NoTypeInformation


    Best Regards,
    Niko Cheng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年6月14日 8:58
    版主
  • Hi Justin,

    I'm just writing to check how's everything going? If you have any questions or needed further help on this issue, please feel free to post back. If the issue has been resolved, please mark the helpful replies as answers, this will make answer searching in the forum easier and be beneficial to other community members as well. Thanks for your understanding.


    Best Regards,
    Niko Cheng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018年6月21日 9:56
    版主
  • Really sorry Niko for not responding. My apologies. Below is the script that i have managed to put up with the help of the community.

    $FirstName = 'FN'
    $LastName = 'LN'
    $UserEmp = 'Identity'
    $To = "EMailaddress@doamain.com"
    $ExtMsgFile = "C:\$UserEmp.htm"
    $OOoConfig = Get-MailboxAutoReplyConfiguration -Identity $UserEmp
    $OOoConfig.ExternalMessage | Out-File $ExtMsgFile
    $BodyText = @"
    Hi Team,
    
    Please see attached the OutOfOffice Message of the user 
    
    FirstName : $FirstName
    LastName : $LastName
    EmpID : $UserEmp
    StartTime : $($OOoConfig.StartTime) 
    EndTime : $($OOoConfig.EndTime)
    "@
    
    $params = @{
        From = 'From address'
        To = $To
        Subject = 'Out Of Office Message of the user'
        SMTPServer = 'SMTP server'
        Attachments = $ExtMsgFile
        Body = $BodyText
    }
    Send-MailMessage @params


    Justin

    2018年6月21日 11:42