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" $ShowVersion = $true if (Test-Path $ModuleManifest) { if ($ShowVersion) { $ModuleVersion = Get-Module $Module | Where-Object Path -Like "*\git\*" | Select-Object Name, Version Write-Verbose "$($ModuleVersion.Name) $($ModuleVersion.Version)" -Verbose } Import-Module $ModuleManifest -Force -Global if ($ShowVersion) { $ModuleVersion = Get-Module $Module | Where-Object Path -Like "*\git\*" | Select-Object Name, Version Write-Verbose "$($ModuleVersion.Name) $($ModuleVersion.Version)" -Verbose } } } |