I'm trying to capture the exception thrown while installing gems, I see the error on the command window however I'm not able to capture the error in catch block, I would like to capture and log in logs file, below is the code.
try{
$tiny= .\gem install --local c:\mypath\tiny_tds-2.1.5-x64-mingw321.gem
if($tiny -eq $null){
throw
}
Write-Host "Installation completed :" $tiny
}
catch{
$string_err = $_ | Out-String
Write-Host "*****************************"
Write-Host $string_err
Write-Host "*****************************"
}
Error that I get on powershell command window