Hello Chris,
I am trying to call a Powershell set of commands that work at the powershell prompt but cannot seem to get them to work as a script. I am not sure where my problem lies, ultimetly I want to call the script or script commands from SAS. The process goes out and finds all business object reports (*.rep) on a network file share I have access to. It makes a very nice CSV file that I read in already in my SAS program and can manipulate the data there perfectly. I just have to call the peaces individually at this point and I was trying to get it all in one SAS program. I use SAS PC if that makes a diferance.

My SAS test code based on your above examples:

%macro fdate(fmt);
%global tdatetime;
data _null_;
call symput("tdatetime",left(put(DATETIME(),&fmt)));
run;
%mend fdate;
%fdate(datetime22.2);
%let test="go &tdatetime.";
%put &test.;
filename process pipe "powershell -noprofile -executionpolicy bypass -File""Z:\My_path1\My_path2\File_Extension_Search_for_rep_Script_PowerShell_with_last_modified.psl""";
%fdate(datetime22.2)
%let test="stop &tdatetime.";
%put &test.;

My logs if this might help in trouble shooting:

161 %macro fdate(fmt);
162 %global tdatetime;
163 data _null_;
164 call symput("tdatetime",left(put(DATETIME(),&fmt)));
165 run;
166 %mend fdate;
167 %fdate(datetime22.2);

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

168 %let test="go &tdatetime.";
169 %put &test.;
"go 11MAY2018:09:05:55.10 "
170 filename process pipe "powershell -noprofile -executionpolicy bypass
170! -File""Z:\My_path1\My_path2\File_Extension_Search_for_rep_Script_PowerShell_with_last_m
170! odified.psl""";
171 %fdate(datetime22.2)

NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

172 %let test="stop &tdatetime.";
173 %put &test.;
"stop 11MAY2018:09:05:55.11 "

my PowerShell code:

$time = (Get-Date).ToString("yyyy.MM.dd")
$Search = "Y:\"

$Outfile = "\\My_server.My_domain\My_share1\My_path1\My_path2\GA_report_$time.csv"

$Files = Dir $Search -recurse -include *.rep -EA SilentlyContinue |
select-object Length,name,Fullname,extension,LastWriteTime | sort-Object extension

$Files | Export-Csv $Outfile -NoTypeInformation

$Files | Group extension -NoElement | % {$Ext = $_.Name;$_ | Select @{N="Extension";E={$_.Name}},Count,`
@{N="SizeMB";E={"{0:N2}" -f (($Files | ?{$_.extension -eq $Ext} | Measure Length -Sum).Sum /1MB)}}} |
ConvertTo-Csv -NoTypeInformation | Out-File $Outfile -Append -Encoding ASCII

$Search = "Z:\"

$Outfile = "\\My_server.My_domain\My_share1\My_path1\My_path2\IR_report_$time.csv"
$Files = Dir $Search -recurse -include *.rep -EA SilentlyContinue |
select-object Length,name,Fullname,extension,LastWriteTime | sort-Object extension

$Files | Export-Csv $Outfile -NoTypeInformation

$Files | Group extension -NoElement | % {$Ext = $_.Name;$_ | Select @{N="Extension";E={$_.Name}},Count,`
@{N="SizeMB";E={"{0:N2}" -f (($Files | ?{$_.extension -eq $Ext} | Measure Length -Sum).Sum /1MB)}}} |
ConvertTo-Csv -NoTypeInformation | Out-File $Outfile -Append -Encoding ASCII

Again my long term goal is to get the results of the PowerShell process into SAS for analisys all in one SAS program (of course calls to PowerSell okay).

Thanks for any advise you might be able to provide. I hope this is an easy one to spot, I know its a bit verbos on the code and question side sorry. -Keith