I have 2 powershell scripts one processes low level xmfiles, the other reads in a top level xml file, pulls out ID values from it and then tries to call the low level xml file processing script, passing in the ID. I developed the low level file first using a hard coded ID and it all now works fine. I added param($ID) at the very top of the called file. I then tried to call the file from the parent xml script thus:
./ChildXmlFile.ps1 "xyz"
This gives me an error:
./ChildXmlFile.ps1 is not recognized as the name of a cmdlet, function, script file, or operable program.
I tried forward slash, back slash, with and without '.ps1' on the end, same result every time.
Is there a way of calling the script from the parent? They both reside in the same directory on disk. My working directory if you like.
Many thanks
您可以点源脚本,如下所示:
. .\ChildXmlFile.ps1 "xyz"
Powershell scripts don't inherit the directories of their parents when they are called for some reason - not doubt a security "feature". They start in the home directory of the user. I ran into this a couple of weeks ago and fixed it by passing the directory as an argument and doing a "cd" to that directory. I know this is a terrible hack, still looking for a good way to do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.