The New-Alias cmdlet creates a new alias in the current Windows PowerShell session.
Aliases created by using New-Alias are not saved after you exit the session or close Windows PowerShell.
You can use the Export-Alias cmdlet to save your alias information to a file.
You can later use Import-Alias to retrieve that saved alias information.
Examples
Example 1
New-Alias list get-childitem
This command creates an alias named "list" to represent the Get-ChildItem cmdlet.
Example 2
New-Alias -Name w -Value get-wmiobject -Description "quick wmi alias" -Option ReadOnly
Get-Alias -Name w | Format-List *
This command creates an alias named "w" to represent the Get-WMIObject cmdlet.
It creates a description, "quick wmi alias", for the alias and makes it read only.
The last line of the command uses Get-Alias to get the new alias and pipes it to Format-List to display all of the information about it.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
cf
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Description
Specifies a description of the alias.
You can type any string.
If the description includes spaces, enclose it in quotation marks.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Force
If set, act like set-alias if the alias named already exists.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Name
Specifies the new alias.
You can use any alphanumeric characters in an alias, but the first character cannot be a number.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
1
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-Option
Specifies the value of the Options property of the alias.
Valid values are:
None: The alias has no constraints (default value)
ReadOnly: The alias can be deleted but cannot be changed except by using the Force parameter
Constant: The alias cannot be deleted or changed
Private: The alias is available only in the current scope
AllScope: The alias is copied to any new scopes that are created
Unspecified: The option is not specified
To see the Options property of all aliases in the session, type Get-Alias | Format-Table -Property Name, Options -AutoSize.
Returns an object representing the new alias.
By default, this cmdlet does not generate any output.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Scope
Specifies the scope of the new alias.
Valid values are "Global", "Local", or "Script", or a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent).
"Local" is the default.
For more information, see about_Scopes.
Parameter properties
Type:
String
Default value:
Local
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Value
Specifies the name of the cmdlet or command element that is being aliased.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
2
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
wi
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
Inputs
None
You cannot pipe input to this cmdlet.
Outputs
None or System.Management.Automation.AliasInfo
When you use the Passthru parameter, New-Alias generates a System.Management.Automation.AliasInfo object representing the new alias.
Otherwise, this cmdlet does not generate any output.