< Back

Expand-Alias

Sun Jan 19, 2020 6:46 pm

NAME Expand-Alias



SYNOPSIS

Expands aliases (optionally adding the fully qualified module name) and short parameters





SYNTAX

Expand-Alias [-File] <FileInfo> [-InPlace] [-AllowedModule <String[]>] [-AllowedCommand <String[]>]

[-AllowedVariable <String[]>] [-Unqualified] [<CommonParameters>]



Expand-Alias -Script <String> [-AllowedModule <String[]>] [-AllowedCommand <String[]>] [-AllowedVariable

<String[]>] [-Unqualified] [<CommonParameters>]



Expand-Alias [[-History] <Int32[]>] [-AllowedModule <String[]>] [-AllowedCommand <String[]>] [-AllowedVariable

<String[]>] [-Unqualified] [<CommonParameters>]



Expand-Alias -Count <Int32> [-AllowedModule <String[]>] [-AllowedCommand <String[]>] [-AllowedVariable <String[]>]

[-Unqualified] [<CommonParameters>]





DESCRIPTION

Expands all aliases (recursively) to actual functions/cmdlets/executables

Expands all short-form parameter names to their full versions

Works on files or strings, and can expand "inplace" on a file





PARAMETERS

-File <FileInfo>

The script file you want to expand aliases in



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-InPlace [<SwitchParameter>]

Enables replacing aliases in-place in files instead of into a new file



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Script <String>

The script you want to expand aliases in



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-History <Int32[]>

The History ID's of commands you want to expand (this supports generating scripts from previous commands, see

examples)



Required? false

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Count <Int32>

The count of previous commands (from get-history) to expand (see examples)



Required? true

Position? named

Default value 0

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-AllowedModule <String[]>

Allows you to specify a list of modules that are allowed in the scripts we're resolving.

Defaults to the currently loaded modules, but specify "*" to allow ANY module.



Required? false

Position? named

Default value $(@(Microsoft.PowerShell.Core\\Get-Module | Select -Expand Name) +

'Microsoft.PowerShell.Core')

Accept pipeline input? false

Accept wildcard characters? false



-AllowedCommand <String[]>

A list of commands that are allowed even if they're not in the AllowedModule(s)



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-AllowedVariable <String[]>

A list of variables that are allowed even if they're not in the AllowedModule(s)



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Unqualified [<SwitchParameter>]

Allows you to leave the namespace (module name) off of commands

By default Expand-Alias will expand 'gc' to 'Microsoft.PowerShell.Management\\Get-Content'

If you specify the Unqualified flag, it will expand to just 'Get-Content' instead.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Expand-Alias -Script "gcm help"















RELATED LINKS