BUG: $adtSession variables not available in PSAppDeployToolkit.Extensions.psm1

Hey team,

I am using version 4.1.7, and I have not tried 4.1.8, but didn't see any changelog apparent to the issue I'm having.

I have custom functions I ported over and have known be be working in toolkit 3.X, and I've made all changes to adapt to the 4.1.X specs.

I'm doing simple calls referencing the adtSession variables, such as:
$adtSession.AppName
$adtSession.AppVersion
$adtSession.AppVendor

The weirdest part is, when I call the installer via the EXE (Invoke-AppDeployToolkit.exe -DeploymentType Install), in the log file, I see it fail while executing my custom function with an error: "The variable '$adtSession' cannot be retrieved because it has not been set.

When I do the exact same action, but by calling the PS1 file in the command line with the exact same code, the installation goes through successfully.

Could you guys confirm this is a known bug that is already, or is going to be resolved in a future release?

Luckily, my function is versatile enough to allow an admin to override the parameters, so I'll be fine for this case.

Thanks

Not a bug, just a misunderstanding around how modules work. Modules have their own execution context/session state and therefore variables can't be shared between modules or callsites. If you need access to your session, call Get-ADTSession to retrieve it.

For posterity also, even if this was a bug, this forum is absolutely not the place to raise bug reports. All bug reports should be done on our GitHub page.

2 Likes