Reputation: 47
Hi all I am not able to log the errors or the content from the other function which are getting called from main function
cls
function one
{
$logFile = "mypath\errorlog.log"
Start-Transcript -path $logFile -Append | Out-Null
try
{
two
}
catch
{
}
finally
{
Stop-Transcript
}
}
function two
{
$arguments = @("`"$myfile`"", "/s:`"$logPath`"")
Start-Process -FilePath myexepath -ArgumentList $arguments -wait
// when ever there are errors or some thing that is getting logeed in to $logPath that is not getting writing in to my Transcript
}
So can some one help me
Upvotes: 0
Views: 366
Reputation: 2342
You are catching the error that is thrown by 2. Also, why are you calling Stop-Transcript inside of finally. Look at this Get-Help about_Try_Catch_Finally.
Clear-Host
function one {
$logFile = "mypath\errorlog.log"
Start-Transcript -Path $logFile -Append | Out-Null
try {
two
}
catch {
Write-Error $_
}
Stop-Transcript
}
function two {
$arguments = @("`"$myfile`"", "/s:`"$logPath`"")
Start-Process -FilePath myexepath -ArgumentList $arguments -wait
# when ever there are errors or some thing that is getting logeed in to $logPath that is not getting writing in to my Transcript
}
Upvotes: 1