Jump to content
Ketarin forum

Powershell: use global variable before updating

Recommended Posts

I'm trying the following:
define a global variable, e.g. "7zip"
create a PowerShell "before updating" global command: "$7zip = $GlobalVars.'7zip'.CachedContent"
then try using this in a PowerShell command "after downloading":  $7zip x c:\temp\test.zip

This is not working, it seems that $7zip is not defined when "after downloading" script is executed.

Any ideas how to solve that? Putting "$7zip = $GlobalVars.'7zip'.CachedContent" within the "after download" section works but then I'd have to put it in every application which I want  to avoid...

Link to post
Share on other sites

Two issues I see.

1) I think you're confusing the Ketarin term "global variable" with PowerShell variables.

2) PowerShell scripts are self-contained - they don't exist outside of themselves and any values you want to use within a script need to be extracted within the script itself.

However, to address your problem I recommend just adding the folder your 7zip executable is in (or the folder Ketarin resides within) to the PATH variable so you can avoid the problem completely. We've had similar issues like this in the past and I know many of us have added our Ketarin folders to the PATH and we just put our utilities in the same folder as Ketarin. 

Link to post
Share on other sites

thx @shawn for your answer.

1) no I got it right, my example isn't described enough, I assume I know the difference

2) this explains why it isn't working and was already coming to my mind that the scripts are running for themselves

and thx again for a possible workaround addressing my issue

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.