Functions/Import-MyModule.ps1
function Import-MyModule { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ArgumentCompleter( { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters ) Get-ChildItem "$(Join-Path $($env:USERPROFILE) -ChildPath "Git\")$wordToComplete*" -Directory -Name | ForEach-Object { "`"$_`"" } } )] [ValidateScript( { $_ -in (Get-ChildItem "$(Join-Path $($env:USERPROFILE) -ChildPath "Git\")" -Directory -Name) } ) ] [string] $Module, [Parameter()] [switch] $ShowVersion ) $ModuleManifest = "$(Join-Path $($env:USERPROFILE) -ChildPath "Git")\$($Module)\$Module.psd1" if (Test-Path $ModuleManifest) { if ($ShowVersion) { Get-Module $Module -ListAvailable -ea 0 } Import-Module $ModuleManifest -Force -Global if ($ShowVersion) { Get-Module $Module } } } |