To enable the Wake flag, we need ConfigurationManager module. This was in the module manifest in Required Modules, however get-pc is functional without ConfigurationManager so it didn't make sense for get-pc to fail importing if ConfigurationManager wasn't present. Removing it from Required Modules and importing it at the bottom of Get-PC.psm1 allows the import to fail silently and the lost functionality isn't reported until user attempts to use the Wake flag (which is a good thing).
23 lines
876 B
PowerShell
23 lines
876 B
PowerShell
$functionFolders = @('Public', 'Private', 'Classes')
|
|
ForEach ($folder in $functionFolders)
|
|
{
|
|
$folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder
|
|
If (Test-Path -Path $folderPath)
|
|
{
|
|
Write-Verbose -Message "Importing from $folder"
|
|
$functions = Get-ChildItem -Path $folderPath -Filter '*.ps1'
|
|
ForEach ($function in $functions)
|
|
{
|
|
if($folder -eq 'Public'){
|
|
Write-Verbose -Message " Importing $($function.BaseName)"
|
|
}
|
|
Write-Verbose -Message " Importing $($function.BaseName)"
|
|
. $($function.FullName)
|
|
}
|
|
}
|
|
}
|
|
$publicFunctions = (Get-ChildItem -Path "$PSScriptRoot\Public" -Filter '*.ps1').BaseName
|
|
Export-ModuleMember -Function $publicFunctions
|
|
|
|
# Optional modules to import for certain functions
|
|
Import-Module ConfigurationManager # -Wake |