Last active
February 7, 2023 07:11
-
-
Save altrive/6733868 to your computer and use it in GitHub Desktop.
Sample code to defer PowerShell modules loading.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Register OnIdle event to load PS moduless. | |
Register-EngineEvent -SourceIdentifier ([Management.Automation.PsEngineEvent]::OnIdle) -MaxTriggerCount 1 -Action { | |
Import-Module TabExpansion++ | |
#Import-Module FunctionExplorer | |
Import-Module VariableExplorer | |
Import-Module PSCodeAnalyzer.ISEAddin | |
Import-Module Altrive.ISEExtensions | |
#Remove current Job (No Need to get job result) | |
$EventSubscriber.Action | Remove-Job -Force -ErrorAction Ignore | |
#Note:PSModule Loading error is not returned. | |
} > $null | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is 7 years old and I've only discovered it now!? It's incredibly useful. 👏🏻