Community 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
2018-12-13T12:14:23Z
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
2018-12-13T13:54:51Z
Try:

{PATH(GetFileName|{TASK(Active|FilePath)})}
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
SynthosCZ
2018-12-14T06:47:32Z
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
2018-12-14T09:05:38Z
Pass it as a parameter instead.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top