Strange character error when running native cmdline app

Welcome Forums General PowerShell Q&A Strange character error when running native cmdline app

Viewing 2 reply threads
  • Author
    Posts
    • #22057
      Participant
      Topics: 5
      Replies: 7
      Points: 1
      Rank: Member

      Howdy,

      I’ve been trying to produce just a simple script (pasted at bottom) which will run a native cmdline application (psftp) and which that native app will run using its own command script – a script also created by the powershell script. However I’m having a lot of difficulty with this and I don’t understand why. I even put the native app and args in its own batch script (rsynctemp.bat) and had Powershell run that instead, to no avail. Every time I run the PS script it errors with the following:

      It looks like when it is trying to execute the batch script (or the command by itself) Powershell is feeding it erroneous characters. Unless I missing some here-string gotchas that I’m not aware of, I don’t really see anything particularly wrong with them.

      What’s particularly interesting is that I can pop open the Powershell shell and test out the native app by running the rsynctemp.bat straight from the prompt and it’ll work great. It’s only when trying to do it from this script does it bug out.

      Script:

    • #22058
      Inactive
      Topics: 9
      Replies: 2322
      Points: 0
      Rank: Member

      Most command-line utilities don’t handle Unicode, and that’s the default encoding used by Out-File. Try adding -Encoding Ascii to all of those calls to Out-File.

    • #22130
      Participant
      Topics: 5
      Replies: 7
      Points: 1
      Rank: Member

      Wonderful. I totally did not recognize the Unicode output. Thank you!

Viewing 2 reply threads
  • The topic ‘Strange character error when running native cmdline app’ is closed to new replies.

One thought on “Strange character error when running native cmdline app

  1. Pingback: PowerShell – PowerShell generated batch file results in error þ is not recognized as an internal or external command | blog.bjornhouben.com

Comments are closed.