PSADT v4: How to access $adtSession from Extension

Hi,
I´m, just migrating from v3 to v4, also my extensions.

now i come to the point where i also want to migrate our former Extension to new Modules

1.)
At version 3 it was able to use the global Variables from this extensions like $installTitle
I know in v4 this would be $adtSession.InstallTitle.

But how i could access the current $adtSession Object from an loaded extension?
I tried, but it´s not available in the global context.

2.)
is this $adtSession forseen to be used for Extension Data, too ?
just say we have an extension generating an environment for all installations based on Registry Data. To keep this logic (Business logic) on one place we use it in an Extension/Module.

it would be great if the state of this extension (success, failure, partly,…) could be saved also in the $adtSession and then be used by the installation script.
Currently i could not resolve the $adtSession from an Extension … (see alos 1)
Is there a plan to create additional functiosn to maintain additional Session Variables (CRUD)?

thanks for your work!

You call Get-ADTSession wherever you need access to the active session.

1 Like

did it work for you? i’m trying to use those variables in config.psd1 to name the logfile name with $adtSession.Appname.

If you want a custom name, you’re supposed to pass -LogName through on your Open-ADTSession call. With that in mind, you might do something like:

$adtSession = @{
    # App variables.
    AppVendor = 'SomeVendor'
    AppName = 'SomeApp'
    AppVersion = '1.2.3'
    AppArch = ''
    ...
}
$adtSession.LogName = "$($adtSession.AppVendor)_$($adtSession.AppName)_$($adtSession.AppVersion).log"
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.