V4.0.6 Extensions: Is it a mistake or is it intentional?

If I create a new module and copy it to the PSAppDeployToolkit.Extensions folder.
Like: $PSSCriptfolder\PSAppDeployToolkit.Extensions\aNewModule.psm1 (include aNewModule.psd1)
then this module is not loaded automatically.
Because of code in Invoke-AppDeplyToolkit.ps1

 Get-Item -Path $PSScriptRoot\PSAppDeployToolkit.* | & {
        process
        {
            Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
            Import-Module -Name $_.FullName -Force
        }
    }

If I rename my Module to PSAppDeployToolkit.aNewModule.psm1 the Modul will also not load automaticly but If i change the code and Add the Folder “PSAppDeployToolkit.Extensions” to the Get-Item then will load the new Module automaticly in the Initialization phase

    Get-Item -Path $PSScriptRoot\PSAppDeployToolkit.Extensions\PSAppDeployToolkit.* | & {
        process
        {
            Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
            Import-Module -Name $_.FullName -Force
        }
    }

Yes, because you shouldn’t be doing it like that. A new module should be in its own folder. If its name has m starts with the PSAppDeployToolkit. namespace, it’ll auto-import.

Please also make the new module using the New-Module cmdlet, don’t make it by hand. A module is more than a .psm1 file, it should have an associated .psd1 file alongside it.

FYI: the New-Module cmdlet is not in v4.0.6.

@EF-Alex, you have a choice:

  1. Create the PSAppDeployToolkit.Extensions folder, PSD1 and PSM files by hand.

or

  1. Get a beta version of V4.1.0 that has the New-Module cmdlet.
    You will still need to edit the PSD1 and PSM files

I did Option 1 because I started my module with PSADT V4.0.3
I know what has to match-up for PSADT to auto-import your module.

Can I read this anywhere?
I mean I read the reference and I can not fine like how to add a own module ( of course the psm1 and psd1 files)
I just read at the deployment strukture:

├───PSAppDeployToolkit.Extensions # PSADT Extensions module files. # TODO - write more on this
│ PSAppDeployToolkit.Extensions.psd1
│ PSAppDeployToolkit.Extensions.psm1

I think I just use the choice 1 until I get new information about customising the toolkit with module.

Thank you

Alex

I just used PSAppDeployToolkit.Extensions as an example.
You have to edit the psd1 file and match it contents with what you are calling your extension.
You have to change the GUID inside the PSD1. (they need to be unique across all PowerShell modules.)

The New-Module cmdlet is built into PowerShell: New-Module (Microsoft.PowerShell.Core) - PowerShell | Microsoft Learn

Sorry, I thought I was clear enough when I said " If its name has m starts with the PSAppDeployToolkit. namespace, it’ll auto-import.".

Take my PSAppDeployToolkit.WinGet module (GitHub - mjr4077au/PSAppDeployToolkit.WinGet: A PSAppDeployToolkit v4 extension module for WinGet.), you literally just download it and place the PSAppDeployToolkit.WinGet folder alongside the toolkit and it’ll auto-import as stated since its name begins with PSAppDeployToolkit.*.

1 Like

Sorry my fault. I just succeeded tested it. Well i just want to know where can i read this in the documents like the reference. And of course everybody can check the code to find out the answer.