- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to find the best solution for executing a powershell script from a sas program. I have found a few articles that discuss pulling information into SAS EG with powershell or calling SAS EG jobs using powershell but I have not seen anything that will show me how to execute a powershell command to run a script.
Any help would be appreciated.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I figured it out by pieceing some articles I found together.
Within a SAS program, insert the following code.
%let machine = pp7h56j082; /* Machine name with admin privledges */
x 'C:\Windows\syswow64\Windowspowershell\v1.0\powershell.exe' -file "L:\Powershell Files\PrintFromExcelToPDF.ps1" &machine;
The Macro sets the machine name that has administrator permissions in order to call the powershell commands in the .ps1 file. The remaining code opens powershell via windows command and passes in the powershell command to execute the powershell script needed.
Hope this helps others!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I figured it out by pieceing some articles I found together.
Within a SAS program, insert the following code.
%let machine = pp7h56j082; /* Machine name with admin privledges */
x 'C:\Windows\syswow64\Windowspowershell\v1.0\powershell.exe' -file "L:\Powershell Files\PrintFromExcelToPDF.ps1" &machine;
The Macro sets the machine name that has administrator permissions in order to call the powershell commands in the .ps1 file. The remaining code opens powershell via windows command and passes in the powershell command to execute the powershell script needed.
Hope this helps others!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your code is not syntactically correct.
- there is a missing single quote to close the command string
- single quotes prevent the resolution of the macro variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @Kurt_Bremser. It was a typo in my code but it seemed to work anyway. I have corrected the code and the post above. I appreciate the heads up!