Powershell : Unable to export output to the file.

  • Not getting the error msg in the output. Kindly assist

    clear-host

    $Error.Clear()

    $WarningPreference = "Continue"

    $VerbosePreference = "Continue"

    try {

    $SqlResourceMon = invoke-sqlcmd -serverinstance "servername" -database master -inputfile "C:\folder\sql_script.sql" -WarningAction SilentlyContinue -OutputSqlErrors $false -verbose 4>&1 | out-file -FilePath "C:\folder\Output_SQLServer\sqllog.txt"

    $SqlResourceMon

    $Error

    }

    catch {

    $Error | out-file -filepath "C:\folder\Output_SQLServer\sqllog1.txt"

    $Error

    }

    Thanks.

  • Just wondering if the following is the source of the grief:

    -OutputSqlErrors $false

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply