<?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: Powershell command not working in SAS but does in CMD. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536978#M147628</link>
    <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Hi, the compress-archive and expand-archive cmdlets are only implemented in Version 5.0 or later of Powershell&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;You can determine your PS Version by typing &lt;STRONG&gt;$psversiontable&lt;/STRONG&gt; on the machine&amp;nbsp;on which SAS is being run&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Feb 2019 06:55:44 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2019-02-20T06:55:44Z</dc:date>
    <item>
      <title>Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536870#M147588</link>
      <description>&lt;P&gt;I am writing a program to automate a very tedious part of my monthly processes. The first part of that Process is to Unzip a ton of Files, so I've been running many many different test programs to get Unzipping to work. And nothing has Worked, the biggest thing that gets me is, when I run a call system command, it outputs a 0 saying the command worked (I know this is right from other call systems I use in other programs) but nothing Happens, I copy the same code into my CMD and it runs, and it does what it is supposed to, is there anything that could be preventing it from working? here is my Code:(modified for security purposes)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options noxwait;&lt;BR /&gt;
data testOutput;

	command = "PowerShell Expand-Archive -Path C:\Temp2\Temp1.zip -DestinationPath C:\Temp2 -Force";	
        rc = system(command);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Feb 2019 19:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536870#M147588</guid>
      <dc:creator>Nyfaria</dc:creator>
      <dc:date>2019-02-19T19:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536881#M147593</link>
      <description>&lt;P&gt;When running external commands, use the filename pipe method:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename oscmd pipe "PowerShell Expand-Archive -Path C:\Temp2\Temp1.zip -DestinationPath C:\Temp2 -Force 2&amp;gt;&amp;amp;1";

data _null_;
infile oscmd;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will find all system responses in the SAS log (the 2&amp;gt;&amp;amp;1 redirects stderr to stdout).&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 19:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536881#M147593</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-19T19:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536895#M147599</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you tried using a ZIP filename statement instead of using an extermal command? - here is a starting point:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" target="_self"&gt;https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 20:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536895#M147599</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-02-19T20:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536898#M147600</link>
      <description>I did this and got:&lt;BR /&gt;Expand-Archive : The term 'Expand-Archive' is not recognized as the name of a&lt;BR /&gt;cmdlet, function, script file, or operable program. Check the spelling of the&lt;BR /&gt;name, or if a path was included, verify that the path is correct and try again.&lt;BR /&gt;&lt;BR /&gt;Which makes no sense, because It definitely is a cmdlet.</description>
      <pubDate>Tue, 19 Feb 2019 20:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536898#M147600</guid>
      <dc:creator>Nyfaria</dc:creator>
      <dc:date>2019-02-19T20:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536899#M147601</link>
      <description>This will not function well in my final product.</description>
      <pubDate>Tue, 19 Feb 2019 20:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536899#M147601</guid>
      <dc:creator>Nyfaria</dc:creator>
      <dc:date>2019-02-19T20:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536901#M147602</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/262849"&gt;@Nyfaria&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I did this and got:&lt;BR /&gt;Expand-Archive : The term 'Expand-Archive' is not recognized as the name of a&lt;BR /&gt;cmdlet, function, script file, or operable program. Check the spelling of the&lt;BR /&gt;name, or if a path was included, verify that the path is correct and try again.&lt;BR /&gt;&lt;BR /&gt;Which makes no sense, because It definitely is a cmdlet.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It clearly is not, in the context of the SAS session. If this is actually a command stored in a file, supply the absolute path to it.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 20:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536901#M147602</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-19T20:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536918#M147613</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;implied, a command session opened from SAS may differ from a command session opened from the desktop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can run other commands using the piped INFILE, such as SET, to know more about the system session available to SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 21:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536918#M147613</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-02-19T21:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536970#M147623</link>
      <description>&lt;P&gt;SAS will execute an external command using cmd.exe (at least by default).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, can you try this &lt;STRONG&gt;from a cmd console&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -ExecutionPolicy Unrestricted -Command $PSVersionTable&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You may not need the full path to Powershell, but it shouldn't hurt.&amp;nbsp; Obviously replace the full path with whatever is in your environment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, in SAS:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename cmd1 pipe "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -ExecutionPolicy Unrestricted -Command $PSVersionTable";

data _null_;
   infile cmd1;
   input;
   put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In my environment, I get this on my desktop (laptop):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name                           Value
----                           -----
PSVersion                      5.1.17134.407  &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.407
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this on my SAS server:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name                           Value                                           
----                           -----                                           
CLRVersion                     2.0.50727.5485                                  
BuildVersion                   6.1.7601.17514                                  
PSVersion                      2.0      &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;                                       
WSManStackVersion              2.0                                             
PSCompatibleVersions           {1.0, 2.0}                                      
SerializationVersion           1.1.0.1                                         
PSRemotingProtocolVersion      2.1         &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hitting Google ("powershell expand-archive not recognized"), it looks like Expand-Archive is a recent addition (Powershell 4?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can replicate your issue in my environment - it works from my desktop, but not from my SAS environment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See if that's your problem.&amp;nbsp; If so, there are various fixes, AFAIK all of them involving your SAS Administrator (install WinZip / 7-Zip, upgrade Powershell).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 05:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536970#M147623</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-02-20T05:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536978#M147628</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Hi, the compress-archive and expand-archive cmdlets are only implemented in Version 5.0 or later of Powershell&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;You can determine your PS Version by typing &lt;STRONG&gt;$psversiontable&lt;/STRONG&gt; on the machine&amp;nbsp;on which SAS is being run&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 06:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/536978#M147628</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2019-02-20T06:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell command not working in SAS but does in CMD.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/537416#M147809</link>
      <description>You are my Hero! Thanks for being the First person in the history of my asking for help online to Actually Answer the question I asked and not try and make me do things in a different way because they like that way better.</description>
      <pubDate>Thu, 21 Feb 2019 15:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Powershell-command-not-working-in-SAS-but-does-in-CMD/m-p/537416#M147809</guid>
      <dc:creator>Nyfaria</dc:creator>
      <dc:date>2019-02-21T15:03:42Z</dc:date>
    </item>
  </channel>
</rss>

