To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product, version and build: 5.6.169
32 or 64 bit version of product: 64
Operating system: Win10
32 or 64 bit OS: 64
I have a very simple script that pulls artifacts and compresses them. The script defaults to collect to the root of C: based on a pre-populated text box and didn't allow the user to edit the file path until I had a request to make the box dynamic. I have enabled the textbox (disabled the read only function) and I now have a folder modern browser dialog so it can be dynamically populated.
My main button is a job button which keeps the form responsive, great. But the job doesn't seem to like taking the $path variable. Path is assigned to "$path = textbox1.text" which is populated from the user selection for where the logs need to go.
The catch is that if I take the exact same code, remove it from the job button, and put it in a standard button, it works. I can place my output in the downloads folder, on the desktop, etc. As soon as I try the exact same code in the job, it reverts back to the root of C: for some unknown reason.
I had two thoughts: 1. for a job, maybe I need to declare a global variable although $path is declared upon button press 2. The old variable for $path was "$path = C:" and I thought that may be cached somewhere? Thoughts?
Variable Within Job
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Variable Within Job
[Topic was moved by moderator to PowerShell GUI forum]
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Variable Within Job
Hi DFIR-CLE,
It sounds like a scope issue. When calling the job you should just use the textbox as a source for thepath as the textbox is always the current value aas selected. In programming we try to not use interim variables as they are seldom needed and lead to errors like you are seeing.
Since we don't have your code it is impossible to know what your full issue is since a null variable will behave like a root path is the current path is at the root.
I suspect this is how you are passing the variable:
-ArgumentList $path
This should be:
-ArgumentList $textbox1.Text
I also recommend renaming all controls to names that indicate their purpose such as "$folderBrowserTextbox".
It sounds like a scope issue. When calling the job you should just use the textbox as a source for thepath as the textbox is always the current value aas selected. In programming we try to not use interim variables as they are seldom needed and lead to errors like you are seeing.
Since we don't have your code it is impossible to know what your full issue is since a null variable will behave like a root path is the current path is at the root.
I suspect this is how you are passing the variable:
-ArgumentList $path
This should be:
-ArgumentList $textbox1.Text
I also recommend renaming all controls to names that indicate their purpose such as "$folderBrowserTextbox".