I'm trying to achieve the following. In several load processes I have a line of AsciiOutput in case an error occurs.
In the TM1 logging directory I get files with a certain filename pattern, involving the name of the offending process and a timestamp. The file itself contains 1 line, a description of the error.
Now, when all loads are finished, I want to have a chore that sends an email containing all files and their contents - as a summary for the TM1 administrator to look at, process by process.
I wrote a PowerShell script as follows. When I use TI to create a text file containing the script (Prolog tab) and I execute it with ExecuteCommand and the -File option (Epilog tab), it works perfectly. A csv file contains all "filename: error description" combinations.
Code: Select all
vPS = 'Get-ChildItem "D:\Logs\a.txt" | ';
vPS = vPS | 'foreach-object { $fname=[System.IO.Path]::GetFileNameWithoutExtension($_); ';
vPS = vPS | 'get-content $_ | foreach-object { echo $fname": "$_ >> "D:\Logs\output.csv"}}';
DataSourceAsciiQuoteCharacter = '';
AsciiOutput( 'D:\Logs\test.ps1', vPS );
ExecuteCommand( 'powershell.exe -ExecutionPolicy ByPass -file "D:\Logs\test.ps1"', 0 );
Code: Select all
vPS = 'Get-ChildItem "D:\Logs\a.txt" | ';
vPS = vPS | 'foreach-object { $fname=[System.IO.Path]::GetFileNameWithoutExtension($_); ';
vPS = vPS | 'get-content $_ | foreach-object { echo $fname": "$_ >> "D:\Logs\output.csv"}}';
ExecuteCommand( 'powershell.exe -Executionpolicy ByPass -command ' | vPS, 0 );
I am aware that a DOS command can also work, but I am just eager to know what is at stake here.
What is the difference between TI running from a ps1 file (that it creates first by himself), and passing a command ?
Note; in the PS script above I use only 1 file (a.txt) as the source but in reality I loop over the files obeying a filename pattern, files only produced today, etc.
Thanks a lot !
Wim