Skip to content

Do Not Nest Import-Module Calls

TIP

  • Always call Import-Module PSCompletions directly in your $PROFILE or terminal
  • Do not wrap it inside a function or any other script block
  • Nested calls will prevent the module from working properly

Wrong Examples

The following approaches are incorrect — do not do this:

powershell
# ❌ Nesting inside a function
function Import-InternalModule {
    Import-Module PSCompletions
}
Import-InternalModule
powershell
# ❌ Passing a path via variable
$InternalDirPath = 'D:\xxx\PSCompletions.psd1'
function Import-InternalModule($path) {
    Import-Module $path
}
Import-InternalModule $InternalDirPath
powershell
# ❌ Nesting inside a script block
& {
    Import-Module PSCompletions
}

Correct Example

Always call Import-Module PSCompletions directly in your $PROFILE or terminal:

powershell
# ✅ Direct import
Import-Module PSCompletions

Released under the MIT.