EvotecIT / Testimo

Testimo is a PowerShell module for running health checks for Active Directory against a bunch of different tests
MIT License
534 stars 56 forks source link

Portable - Modules do not import correctly #39

Closed mundayn closed 5 years ago

mundayn commented 5 years ago

Running .\Testimo.ps1 did not load all of the Modules.

To resolve this issue I had to run from the directory with the files:

Get-ChildItem -Recurse *.psm1 | ForEach-Object {import-module $_.FullName}

Then import this one manually: Import-Module .\PSWriteColor.psd

Then run this again: Get-ChildItem -Recurse *.psm1 | sort-object -Descending | ForEach-Object {import-module $_.FullName}

Then I could run: Invoke-Testimo -ReturnResults

PrzemyslawKlys commented 5 years ago

I see where I did mistake. I need to read all PSD1 as I did and then from all those PSD1 I need to read their required modules. Importing PSM1 is not enough. While it may work PSD1 provides other data.

PrzemyslawKlys commented 5 years ago

I've rewritten that command.

This is what gets generated into Testimo.ps1 now.

$Modules = @(
   "$PSScriptRoot\Connectimo\0.0.2\Connectimo.psd1"
   "$PSScriptRoot\PSWriteColor\0.86\PSWriteColor.psd1"
   "$PSScriptRoot\PSSharedGoods\0.0.97\PSSharedGoods.psd1"
   "$PSScriptRoot\PSWriteHTML\0.0.52\PSWriteHTML.psd1"
   "$PSScriptRoot\ADEssentials\0.0.14\ADEssentials.psd1"
   "$PSScriptRoot\DSInternals\3.6.1\DSInternals.psd1"
   "$PSScriptRoot\Emailimo\0.0.9\Emailimo.psd1"
   "$PSScriptRoot\PSEventViewer\1.0.7\PSEventViewer.psd1"
   "$PSScriptRoot\PSWinDocumentation.DNS\0.0.8\PSWinDocumentation.DNS.psd1"
   "$PSScriptRoot\PSWinDocumentation.AD\0.1.14\PSWinDocumentation.AD.psd1"
   "$PSScriptRoot\Testimo\0.0.22\Testimo.psd1"
)
foreach ($_ in $Modules) {
   Import-Module $_ -Verbose:$false -Force
}

Of course, I hope it works for more modules then just TEstimo. I've updated the article with new code: https://evotec.xyz/making-powershellgallery-modules-portable/

If you can test please let me know it works.