Script Cannot Find Called Script
Posted: Fri Feb 12, 2021 3:41 pm
Hello Everyone,
I've got a script that I've been working with that is having a strange issue, and it appears to be specific to Powershell Studio. When I try to run the script in Studio, it fails on the following line:
$result = &"\\SERVER\PATH TO SCRIPT\CALLEDSCRIPT.ps1" -Variable1 $var1 -Variable2 $var2
I've cleaned up the actual names but it really doesn't matter. The error I get is as follows:
--------------
& : The term '\\SERVER\PATH TO SCRIPT\CALLEDSCRIPT.ps1' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:12
+ $result = &"\\SERVER\PATH TO SCRIPT\CALLEDSCRIPT.ps1" -Variable1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\SERVER\P...ALLEDSCRIPT.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
--------------
This reads like the script being called isn't accessible or missing, but I have triple-checked the actual path and file about a million times. If I open the called script in Studio directly and run it independently, it runs fine. If I run the calling script outside of Powershell Studio, I get no errors, the script executes fine, calls the desired scripted and everything. This is all on the same workstation under the same profile. Changing between admin and non-admin calls doesn't seem to make a difference. Is there something in Studio I am missing? I'm running Powershell Studio version 5.8.185.0
I AM able to run & call other scripts from Powershell Studio, including those in this exact same directory, using this method of calling other scripts. I've been doing a lot of this lately so I'm very perplexed as to why all of the sudden it's having an issue with just one of many scripts.
Sorry if this is the wrong place for this. It seems like a studio issue but it's also kind of a scripting issue? Happy to repost elsewhere. Thanks!
I've got a script that I've been working with that is having a strange issue, and it appears to be specific to Powershell Studio. When I try to run the script in Studio, it fails on the following line:
$result = &"\\SERVER\PATH TO SCRIPT\CALLEDSCRIPT.ps1" -Variable1 $var1 -Variable2 $var2
I've cleaned up the actual names but it really doesn't matter. The error I get is as follows:
--------------
& : The term '\\SERVER\PATH TO SCRIPT\CALLEDSCRIPT.ps1' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:12
+ $result = &"\\SERVER\PATH TO SCRIPT\CALLEDSCRIPT.ps1" -Variable1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\SERVER\P...ALLEDSCRIPT.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
--------------
This reads like the script being called isn't accessible or missing, but I have triple-checked the actual path and file about a million times. If I open the called script in Studio directly and run it independently, it runs fine. If I run the calling script outside of Powershell Studio, I get no errors, the script executes fine, calls the desired scripted and everything. This is all on the same workstation under the same profile. Changing between admin and non-admin calls doesn't seem to make a difference. Is there something in Studio I am missing? I'm running Powershell Studio version 5.8.185.0
I AM able to run & call other scripts from Powershell Studio, including those in this exact same directory, using this method of calling other scripts. I've been doing a lot of this lately so I'm very perplexed as to why all of the sudden it's having an issue with just one of many scripts.
Sorry if this is the wrong place for this. It seems like a studio issue but it's also kind of a scripting issue? Happy to repost elsewhere. Thanks!