<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I retrieve error in powershell Script ? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-retrieve-error-in-powershell-Script/m-p/818212#M40851</link>
    <description>&lt;P&gt;If you want to know why the abort occurred you may want to consider&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%abort abend 1234;&lt;/PRE&gt;
&lt;P&gt;Where 1234 would be a return code that the operating system receives. You need to check what ranges of values your OS will allow. And 1234 if just an example. You would need to "know" what 1234 means for your program.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2022 21:25:23 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-06-14T21:25:23Z</dc:date>
    <item>
      <title>How can I retrieve error in powershell Script ?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-retrieve-error-in-powershell-Script/m-p/818054#M40849</link>
      <description>&lt;P&gt;Is there a way to retrieve the error in powershell ?&lt;BR /&gt;&lt;BR /&gt;This is an example of my powershell script:&lt;/P&gt;&lt;PRE&gt;$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() #&amp;lt;======= 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()
}&lt;/PRE&gt;&lt;P&gt;When calling Run(), the error is not reported even if I'm using&amp;nbsp;%abort ABEND in the sas macro. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;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&lt;/P&gt;&lt;PRE&gt;proc sql;
insert into MyConnection.MyTable select * from to_insert;
%if &amp;amp;SQLRC &amp;gt; 0 %then %do;
%put ERROR: Error happened!;
%abort ABEND;
%end;
quit;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I put all the code in the autorun.&lt;BR /&gt;If I put a wrong password, I get an error and go in the Catch section.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 11:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-retrieve-error-in-powershell-Script/m-p/818054#M40849</guid>
      <dc:creator>MarcoRQ</dc:creator>
      <dc:date>2022-06-14T11:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I retrieve error in powershell Script ?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-retrieve-error-in-powershell-Script/m-p/818212#M40851</link>
      <description>&lt;P&gt;If you want to know why the abort occurred you may want to consider&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%abort abend 1234;&lt;/PRE&gt;
&lt;P&gt;Where 1234 would be a return code that the operating system receives. You need to check what ranges of values your OS will allow. And 1234 if just an example. You would need to "know" what 1234 means for your program.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 21:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-can-I-retrieve-error-in-powershell-Script/m-p/818212#M40851</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-14T21:25:23Z</dc:date>
    </item>
  </channel>
</rss>

