Do Not Nest Import-Module Calls
TIP
- Always call
Import-Module PSCompletionsdirectly 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-InternalModulepowershell
# ❌ Passing a path via variable
$InternalDirPath = 'D:\xxx\PSCompletions.psd1'
function Import-InternalModule($path) {
Import-Module $path
}
Import-InternalModule $InternalDirPathpowershell
# ❌ 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