Failing to Run Powershell (Resolved)

Hi guys,

So I have been trying to run a Powershell for a while now. but I’m unsure what Im doing wrong.

so I have tried:

Failed waithidden "{parameter "PowerShellexe"}" -file "{__Download}\Remove_old_java_versions.ps1"


Failed waithidden "{parameter "PowerShellexe"}" -file "{pathname of client folder of current site}\Remove_old_java_versions.ps1"


Failed waithidden powershell -executionpolicy bypass -File {__Download\Remove_old_java_versions.ps1}


Failed wait __Download\powershell -executionpolicy bypass -File Remove_old_java_versions.ps1


Failed wait __Download\powershell -executionpolicy bypass -File Remove_old_java_versions.ps1


I also tried to run it from within a .bat and those shows complete but the location inside its a share drive

Not sure if I’m not entering the code correctly or use different parameters.

Also, not sure if i should have more code in between.

Completed prefetch eff1490b3c0ff913f3177e5ef69f17936da2d53b sha1:eff1490b3c0ff913f3177e5ef69f17936da2d53b size:177 http://server.lala.xx:52311/Uploads/eff1490b3c0ff913f3177e5ef69f17936da2d53b/Removeold_java_versions.ps1.tmp sha256:68821d52bbca2cc629ecb8d8c2c7cd98f31d5116a3adff3be57bad624ecf39a5
Completed extract eff1490b3c0ff913f3177e5ef69f17936da2d53b
Failed wait _Download\powershell -executionpolicy bypass -File Removeold_java_versions.ps1

? Did you ever create a Parameter named PowerShellexe ? If not, that substition will fail. Also, you shouldn’t need to set it as a variable anyway, powershell.exe should be in the path.
Also, don’t use "{__Download}\Removeold_java_versions.ps1". In that substitution, the client will expect {__Download} to be a relevance expression; which it’s not. If you wanted to write an expression that returned the __Download string, that would just be {“__Download”}, but in that case you don’t need a substitution at all.

…again, did you ever define a parameter “PowerShellExe”?[quote=“TheCookieMonster, post:1, topic:23566”]

Failed waithidden powershell -executionpolicy bypass -File {_Download\Removeold_java_versions.ps1}
…closer, but {_Download\Removeold_java_versions.ps1} is not a valid substitution because __Download… is not a Relevance expression.

powershell.exe is not in the __Download folder, it should be hanging out at \windows\system32 (and in the system PATH so you don’t need to specify the full path to it anyway)
I’m not sure whether powershell will start in the current working directory, but in any case the downloaded .ps1 script is not in the current directory (__BESData\SiteName), it’ll be under the download folder (__BESData\SiteName\__Download)

So, what I think you should try, is to run the powershell.exe that’s in the system PATH, but use Relevance to get the fully-qualified path to the downloaded .ps1 file. Also, you may need to disable wow64 redirection, so that you’re executing the 64-bit version of powershell and not the 32-bit version (which will make a big difference if you’re trying to remove a 64-bit JRE).

Give this a try -

[download the script]

action uses wow64 redirection false
wait powershell.exe -executionpolicy bypass -File “{pathname of download file “Removeold_java_versions.ps1”}”

Also, I’ll edit your post to put the code tags around your commands. Lines that have "__" in them get interpreted by the forum software as formatting tags so they don’t appear correctly unless you use the code tag on them


Hi Jason,
no, I have not. to be honest. I have never run a powershell script thru bigfix.

I was looking at some posts and I tried to do some of that. but it failed. In one case I tried to have the code in the task and then move it to a ps1. but it was failing.

so, when you mean create a parameter named PowerShellExe is hat exactly. sorry my lingo isnt the greatest yet. I’m learning tho.

Thank you for the pointer. I did not know that.

It did work. Thank you. Thank you, thank you. I have been at this all day. I did add something else that came in handy based on your comment.

and ended up with:

action uses wow64 redirection {not x64 of operating system}
wait powershell.exe -executionpolicy bypass -File "{pathname of download file "Remove_old_java_versions.ps1"}"

I also would like to learn how to do the scripts on the fly. so, I also tried:
but the script error out here

once again Jason, you saved my bacon! Thanks a bunch!

1 Like

I’m glad I was able to help.
When I talk about “creating a parameter”, that’s an ActionScript command to set up a variable so that it can be referenced later in the script. An example might be

parameter "MSIFile"="{pathname of download file "TheInstallerIDownloaded.msi"}"

waithidden msiexec.exe /i "{parameter "MSIFile"}" /qn

As for building the powershell script on the fly, You’re very close. But in ActionScript, any time an open curly bracket { is present, it signifies the start of a Relevance Substitution. You have open curly brackets that are literal parts of the powershell script you are creating, so you have to escape those by putting two open curly brackets. So those two lines should look like

if ($UninstallJava6andBelow) {{
 $32bitJava += Get-WmiObject -Class Win32_Product | Where-Object {{

Likewise, when you are inside of a Relevance Substition and need to represent a close curly bracket as a literal value, and not as the end of the relevance, you need to double it. For example

parameter "InstallPath"="{value "InstallLocation" of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{GUID_OF_PACKAGE}}"}"
In this case the first open curly bracket in {value begins a Relevance Substition. The open curly bracket at the start of the {GUID does not need to be escaped because we are already inside a relevance substition. The close curly bracket at the end of GUID_OF_PACKAGE}} does need to be escaped because we want the literal “}”, not the end of the relevance substition. Then we have another close curly bracket after the quoted key name string that does signify the end of the substitution.