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
}