Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8509211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:22:24+00:00 2026-06-11T03:22:24+00:00

In a Powershell script, I something like this: Invoke-Expression & `C:\Scripts\psftp.exe` ftp.blah.com I want

  • 0

In a Powershell script, I something like this:

Invoke-Expression "& `"C:\Scripts\psftp.exe`" ftp.blah.com"

I want to pipe all output, errors etc of this to the string $output

How can I do this? I’ve tried > at the end as well as $output = ... but neither seem to catch errors and the sort.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:22:25+00:00Added an answer on June 11, 2026 at 3:22 am

    Try this:

    $output = Invoke-Expression "C:\Scripts\psftp.exe ftp.blah.com 2>&1"
    

    The use of the call operator & is unnecessary as is quoting the exe path in this case since the path doesn’t contain spaces. If the path contained spaces, then it would need to be quoted and then you would have to use the call operator. That said, I’m not sure why you need to use Invoke-Expression at all in this case. The following would work just as well given your example.

    $output = C:\Scripts\psftp.exe ftp.blah.com 2>&1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my PowerShell script to print something like this: Enabling feature XYZ......Done The
I'm looking to run some powershell scripts via automation. Something like: IList errors; Collection<PSObject>
I almost have this Powershell script completed but I am stuck at the last
To piggyback onto this question, PowerShell script to delete files from list and output
I have a Powershell script that uses this PowerShell module . It basically allows
I'd like to spawn a process on a remote host from a powershell script
Suppose I have a large number of strings formatted something like: <tag>blah blahXXXXXblah blah</tag>
I want to do something like: exec sproc1 and sproc2 at the same time
I was doing something like described in this post to save credentials in a
I have a set of PowerShell scripts that include a common script, located in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.