Is there a way to retrieve the error in powershell ? This is an example of my powershell script: $sas = New-Object -comObject SASEGObjectModel.Application.7.1
$App=$sas.Open("C:\temp\myTestFile.egp","")
Foreach($parametre in $App.Parameters)
{
If ($parametre.Name -eq "USER")
{
$parametre.Value='MyUser'
}
If ($parametre.Name -eq "PASSWORD")
{
$parametre.Value='{sas002}MyPasswordEncrypted'
}
}
Try {
$output = $App.run() #<======= How can I get the error here ???
Write-Host "Result: " $output}
Catch{
Write-Host "An error occurred:"
Write-Host $_
}
Finally{
$App.save()
$App.close()
$sas.quit()
} When calling Run(), the error is not reported even if I'm using %abort ABEND in the sas macro. 😞 In my sas macro, I simulate an error by inserting the same row 2 times so I want this error reported in the powershell script proc sql;
insert into MyConnection.MyTable select * from to_insert;
%if &SQLRC > 0 %then %do;
%put ERROR: Error happened!;
%abort ABEND;
%end;
quit; I put all the code in the autorun. If I put a wrong password, I get an error and go in the Catch section. Regards,
... View more