Community
    • Login

    PowerShell Encoding issue in 7.8.3

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    1 Posts 1 Posters 798 Views 1 Watching
    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 LucasM Offline
      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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors