Skip to content

Instantly share code, notes, and snippets.

@aggieben
Created January 2, 2013 22:45
Show Gist options
  • Select an option

  • Save aggieben/4439001 to your computer and use it in GitHub Desktop.

Select an option

Save aggieben/4439001 to your computer and use it in GitHub Desktop.
Function Ensure-Module {
Param([string]$name)
if (-not (Get-Module -name $name)) {
if (Get-Module -ListAvailable |? { $_.name -eq $name }) {
Import-Module -Name $name
$true #if available, then import
}
} else {
$false #not loaded, not available
} else {
$true #already loaded
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment