Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    PowerShell Encoding issue in 7.8.3

    Help wanted · · · – – – · · ·
    1
    1
    138
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mark Lucas
      Mark Lucas last edited by

      I have a PowerShell script that was written in Notepad++ and has been working properly for some time. I recently made a change to the script and it stopped working. Digging in, it wasn’t the change I made, but the portion of the script that sends an email with HTML formatting. If I take the script and copy/paste into PowerShell ISE and save, it works fine.

      Problem line:

      $EmailBody += '<font size="3" color="red"><b>Failed to enable Remote Mailbox ' + $AdUser.FirstName + " " + $AdUser.LastName + " (" + $AdUser.userPrincipalName + ').</font></b><br><br>'
      

      PowerShell Error:

      At C:\Scripts\Activate-NewAccounts.ps1:238 char:30
      + ... <font size="3" color="red"><b>Failed to enable Remote Mailbox ' + $Ad ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Unexpected token '3" color="red"><b>Failed to enable Remote Mailbox ' + $AdUser.FirstName + "' in expression or statement.
      At C:\Scripts\Activate-NewAccounts.ps1:238 char:30
      +         $EmailBody += '<font size="3" color="red"><b>Failed to enable ...
      +                                    ~
      Missing closing ')' in expression.
      

      Since a straight copy/paste/save in PowerShell ISE solves the issue with no changes, it appears there’s something in the PowerShell save encoding in the latest version.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright © 2014 NodeBB Forums | Contributors