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 9142525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:48:09+00:00 2026-06-17T09:48:09+00:00

Right now I’m using a line like thus: (based on code others have discussed

  • 0

Right now I’m using a line like thus: (based on code others have discussed on SO)

(New-Object System.Net.WebClient).DownloadFile( $servicePath, $responseFile)

And in a few cases my $servicePath is tossing a 500. While I could very neatly throw that information up in a browser window, I prefer to download it (collection of previous events is a good thing yeah?) into a file and allow others to refer to it later.

The issue is, my try-catch is hitting an exception for the 500 and I’m not sure how to capture the “yellowtext” of the IIS error. How can I do that with PowerShell 2.0? I’m willing to switch from a WebClient to something else, but I would prefer to stay in purely PS space, without adding in a new library if I can do so.

If I attempt it like thus in the powershell ISE, I get the following:

$o = @{};
$err = @{};
try {
  $o = New-Object System.Net.WebClient;
  $o.DownloadFile($servicePath, $responseFile);
} catch { 
  $err = $_;
}

and

$err.Exception.Message => "The remote server returned an error: (500) Internal Server Error."

How can I capture the yellowtext? Obviously my browser can capture the yellowtext as it shows it to me. Do I need to use a HttpWebResponse or something?

  • 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-17T09:48:10+00:00Added an answer on June 17, 2026 at 9:48 am

    AAAAHHHHH I actually have the answer to a problem on here!!!! I had this same problem yesterday!!! 🙂 enough of my ranting. The thing is $o stores that message your getting as an object if you want to actually do anything with it the easiest thing would be to convert it to a string by piping your output to the out-string cmdlet. Now you can do whatever you need to do with the $strerror variable. Let me know if I can be of further assistance.

        $o = @{};
        $err = @{};
        try {
              $o = New-Object System.Net.WebClient;
              $o.DownloadFile($servicePath, $responseFile);
        }catch{ 
               $strerror = ($error[0] | out-string)
               }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
right now I am retrieving images using following piece of code and it is
Right now I'm using OleDbDataAdapter objDataReader = new OleDbDataAdapter(); objDataReader.SelectCommand = myCommand; objDataReader.Fill(myDataTable); But
Right now I am listing all of a users microposts using the code below.
Right now I have a small database with two tables that look something like
Right now, I have an enum like this: public enum ReferenceType { Language =
Right now I have to create a new physical file in eclipse android for
Right now I have my ActionView::Base.field_error_proc as Proc.new do |html_tag, instance| if html_tag =~
Right now, I have a SQL Query like this one: SELECT X, Y FROM
Right now I have an upload field while uploads files to the server. The

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.