App custom Variables removed during conversion to ADT v4

EDIT: I did see when I used the v3 converted to v4, the use of variables (custom or built in) inside a log line or a Progress message, did not convert the variable…so the info I mention in this post, relates to only a v3 script converted to a v4 script. I fresh v4 Template works with displaying variables (Custom or built in) or logging variable data.

I did a conversion from a v3 script to the new v4 and it look pretty good on the surface.
I had 18 custom variables in the v3 and they were removed when I did a conversion in a PS console. I added the variables back in under the "app variables section in the head of the script, following the same format as AppVersion for example.

LogFilePath = "$EnvSystemDrive\IT_BreadCrumbs\Enscape_4.2.1.88_LogStart.txt"

It fails inside the script on this line

if (Test-Path -Path $logFilePath)

Error, the variable ‘logfilePath’ cannot be retrieved because it has not been set.

I ended up trying this in the code and it allowed the script to continue, but it appears to not function with retrieving the variable in a log or display message.
EDIT: I used the format $($ADTSession.logFilePath), in the log file writing and also show dialog box, Progress, etc., and the format for the variable was only returning the formatted code, not the actual variable data. Seeing that i verified the If statement below, showed the variable was working within the script (allowing the If statement to find that variable and continue, the main issue I have is I can’t get dialogs or the logging to actually convert the variable.

if (Test-Path -Path $($ADTSession.logFilePath))

It did fail to either write the variable to a log or Progress message.
I tried placing the variable in a log multiple ways and it never worked. It only showed the variable like this in the log or display message. $ADTSession.logfilePath
or $($adtsession.logfilepath)
Any ideas on how to create custom variables and use them in the script sections?
I was able to do custom variables in v3, but none of those converted to a v4 script.
I placed my variables like the first one i showed above, right under the AppScriptAuthor variable, and i followed the format of the system variables.

Just curious if the conversion from v.3 to v.4 is possible going to be updated to take custom variables and convert those in the app variables section and also add the $ADTSession prefix to our in script use of the custom variables we created and remove the $ from our variable name and affix $ADTSession, to the front of the variable?

I’d suggest raising your issue directly on the repository so it has greater developer visibility: GitHub - PSAppDeployToolkit/PSAppDeployToolkit.Tools: Companion module for PSAppDeployToolkit.

This also goes for PSAppDeployToolkit bugs, they’ve got a higher chance of being seen and identified there vs here, which should be reserved for discussions only.

1 Like

Thanks. I thought it was v4.4 as an issue, but it does seem to be the conversion process. I will raise the issue there.

1 Like