Expand-Aliases

This function was introduced in version 0.2.0.

Expands the aliases in either the file or text passed to the function.

Syntax

Expand-Aliases `
    -Text <String> `
    [-AliasWhitelist <String[]>]
Expand-Aliases `
    -Directory <String> `
    [-Filter <String>] `
    [-AliasWhitelist <String[]>]
Expand-Aliases `
    -Files <String[]> `
    [-AliasWhitelist <String[]>]

Description

Any scripts in 'corporate' or 'formal' use should have any aliases expanded. This this removes ambiguity and any potential clashes or errors.

Aliases

None

Examples

Example 1

Expand-Aliases -Text "rm file.txt; gi file.exe"

Should be expanded to "Remove-Item file.txt; Get-Item file.exe"

Example 2

Expand-Aliases -Directory .\tools -Filter "*.ps1"

Should traverse the tools directory relative to the current directory, and expand all aliases in files matching the specified filter.

Example 3

Expand-Aliases -Files ".\file1.ps1","text-File.txt"

Should expand all aliases in the two specified files.

Inputs

None

Outputs

None

Required Parameters

-Text <String>

The script text that should parsed for aliases to expand.

Property Value
Aliases
Position? named
Globbing? false
Default Value
Accept Pipeline Input? false

-Directory <String>

The directory to use for parsing files.

Property Value
Aliases
Position? named
Globbing? false
Default Value
Accept Pipeline Input? false

-Files <String[]>

The files to expand aliases in.

Property Value
Aliases
Position? named
Globbing? false
Default Value
Accept Pipeline Input? false

Optional Parameters

-Filter <String>

The filter to use when traversing a directory for files to parse.

Property Value
Aliases
Position? named
Globbing? false
Default Value *.ps1
Accept Pipeline Input? false

-AliasWhitelist <String[]>

Allows to add a array of whitelisted aliases that shouldn't be expanded. (Available since v 0.3.0)

Property Value
Aliases
Position? named
Globbing? false
Default Value @('Get-PackageParameters'; 'Get-UninstallRegistryKey')
Accept Pipeline Input? false
GitHub