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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:57:32+00:00 2026-06-17T18:57:32+00:00

I use powershell to invoke a sql stored procedure, now I want to redirect

  • 0

I use powershell to invoke a sql stored procedure, now I want to redirect the complete set of the output into a .ps1 file, because the the output line is executable in powershell.

I’m trying to use >output.ps1, it works, but I’m checking the output file, it contains a lot of ‘…’ to replace real output.

How to export the complete output? also stripe the header off?

Thanks.

  • 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-17T18:57:33+00:00Added an answer on June 17, 2026 at 6:57 pm

    It depends how you invoke the stored procedure. If you’re invoking it within PowerShell, you should be able to collect the output, so I assume you’re starting it as a separate task its own window. Without your actual example, here’s a way to collect the output from the tasklist.exe command. You may find it applicable.

    cls
    $exe = 'c:\Windows\System32\tasklist.exe'
    $processArgs = '/NH'
    try {
        Write-Host ("Launching '$exe $processArgs'")
        $info = New-Object System.Diagnostics.ProcessStartInfo
        $info.UseShellExecute = $false 
        $info.RedirectStandardError = $true 
        $info.RedirectStandardOutput = $true 
        $info.RedirectStandardInput = $true 
        $info.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
        $info.CreateNoWindow = $true
        $info.ErrorDialog = $false
        $info.WorkingDirectory = $workingDir
        $info.Filename = $exe
        $info.Arguments = $processArgs
    
        $process = [System.Diagnostics.Process]::Start($info)
        Write-Host ("Launched $($process.Id) at $(Get-Date)")
        <# 
        $process.StandardOutput.ReadToEnd() is a synchronous read. You cannot sync read both output and error streams. 
        $process.BeginOutputReadLine() is an async read. You can do as many of these as you'd like. 
        Either way, you must finish reading before calling $process.WaitForExit()
        http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx
        #>
    
        $output = $process.StandardOutput.ReadToEnd()
    
        $process.WaitForExit() | Out-Null 
    
        Write-Host ("Exited at $(Get-Date)`n$output")
    
    } catch {
        Write-Host ("Failed to launch '$exe $processArgs'")
        Write-Host ("Failure due to $_")
    }
    $output
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use Powershell in order to call a batch file on remote
I want to use Powershell to insert entities into Azure Table Storage and therefore
I wanna use powershell to get all the file in sharepoint library EM_DOC_LIBRARY and
A little background: I use PowerShell on windows xp at work and I set
I'd like to use a windows PowerShell script to run a batch file every
I am attempting to use FTP in Powershell to upload a file. I am
I use PS 2.0, VS2010, C# for call Powershell scripts (ps1 files) using C#.
I'm trying to execute an EXE file using a PowerShell script. If I use
I have a Powershell script file called ExecutBizTalkAppMSI.ps1 This contains a single function called
I have to invoke a PowerShell script from a batch file. One of 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.