I have created a poweshell script in which I am trying to find out the current directory in which the ps1 file is executing. When in execute the script from powershell command prompt, i am able to get the path properly. Using the path I am trying to Read some configuration values from a file which is located in the same folder where the script is located.
But once I configure to execute the script as a power shell task in visualCron, I am not able to get the path where my script is executed.
The sample code which I am using is provided below. The output from both the environments, i.e. powershell command and visualCron powershell task are provided below.
echo "##########-START-##########" > \\Server\test\log.txt
echo $MyInvocation.InvocationName >> \\Server\test\log.txt
echo "##########-DONE-##########" >> \\Server\test\log.txt
Output From Powershell Command
##########-START-##########
\\Server\test\test.ps1
##########-DONE-##########
Output from VisualCron server when the same script mentioned above is executed. there is no output path.
##########-START-##########
##########-DONE-##########
My understanding is, Visual Cron reads the content of the ps1 file and then executes it from within the VisualCron environment. If my understanding is correct, how can I get the path of the script file in my power shell script.
Thanks in advance.
Anoop