Powershell - call $MyInvocation - VisualCron - Forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


SynthosCZ
6 years ago
Hello,

I need to read powershell script name during its execution, but standard variable $MyInvocation.MyCommand.Name is always empty. Do you have hint how to get script name launched as Visual Cron task? Same script launched from powershell command line works of course.

Thanks.

Pavel.
Sponsor
Forum information
Support
6 years ago
Try:

{PATH(GetFileName|{TASK(Active|FilePath)})}
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
SynthosCZ
6 years ago
Thanks, but not working. I got error

ExecuteProcess(Q:\VisualCron\\PowerShell\TaskPowerShell.exe 14407644)->System.Management.Automation.ParseException: At line:141 char:55
+ ... = $b.Replace("%SCRIPT%", {PATH(GetFileName|{TASK(Active|FilePath)})})
+ ~~~~~~~~~~~~~~~~~~~~~~~
Expressions are only allowed as the first element of a pipeline.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at TaskPowerShell.PowerShellTaskClass.Run(ProcessPowerShellTaskInfoClass ti, StringBuilder& sbStandardOut, StringBuilder& sbStandardError, Boolean& bolResult)

I suppose it is caused by launching PS1 script file from Visual Cron, not script text.


Pavel.
Support
6 years ago
Pass it as a parameter instead.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top