public/Add-GzPasswordGeneratorAlias.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
$gzAliases = @{ "New-Password" = "New-GzPassword" }; function Remove-GzPasswordGeneratorAlias() { <# .SYNOPSIS Removes the aliases that map to Gz prefixed commands for the Gz-PasswordGenerator module. .DESCRIPTION Removes the aliases that map to Gz prefixed commands. For example, removes the alias New-Password that points to New-GzPassword. .EXAMPLE PS C:\> Remove-GzPasswordGeneratorAlias .INPUTS None .OUTPUTS None .NOTES Aliases are to remove the Gz Prefix #> foreach($key in $gzAliases.Keys) { if($null -ne (Get-Alias $key -EA SilentlyContinue)) { Remove-Item alias:\$key } } } function Add-GzPasswordGeneratorAlias() { <# .SYNOPSIS Adds the aliases that map to Gz prefixed commands for the Gz-PasswordGenerator module. .DESCRIPTION Adds the aliases that map to Gz prefixed commands. For example, adds the alias New-Password that points to New-GzPassword. .EXAMPLE PS C:\> Add-GzPasswordGeneratorAlias .INPUTS Inputs (if any) .OUTPUTS Output (if any) .NOTES Aliases are to remove the Gz Prefix #> foreach($key in $gzAliases.Keys) { if($null -eq (Get-Alias $key -EA SilentlyContinue)) { Set-Alias -Name ($key) -Value $gzAliases[$key] -Scope Global } } } |