NAME
New-Alias
SYNOPSIS
Creates a new Alias.
SYNTAX
New-Alias [-Name] <string> [-Value] <string> [-Description <string>] [-Force] [-Option {None | ReadOnly | Constant | Private | AllScope}] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
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.
PARAMETERS
-Description <string>
Specifies a description of the Alias. You can type any string. If the description includes spaces, enclose it in quotation marks.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Force [<SwitchParameter>]
If set, act like Set-Alias if the Alias named already exists.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Name <string>
Specifies the new Alias. You can use any alphanumeric characters in an Alias, but the first character cannot be a number.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Option <ScopedItemOptions>
Sets one or more optional properties of the Alias. Valid values are:
— None: Sets no options. (default)
— ReadOnly: The Alias cannot be changed unless you use the Force parameter.
— Constant: The Alias cannot be changed, even by using the Force parameter.
— Private: The Alias is available only within the scope specified by the Scope parameter. It is invisible in all other scopes.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns an object representing the new Alias. By default, this cmdlet does not generate any output.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Scope <string>
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.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Value <string>
Specifies the name of the cmdlet or command element that is being Aliased.
Required? true
Position? 2
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actually executing the command.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
“Get-Help 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.
NOTES
To create a new Alias, use Set-Alias or New-Alias. To change an Alias, use Set-Alias. To delete an Alias, use Remove-Item.
————————– EXAMPLE 1 ————————–
C:\PS>New-Alias list Get-ChildItem
Description
———–
This command creates an Alias named “list” to represent the Get-ChildItem cmdlet.
————————– EXAMPLE 2 ————————–
C:\PS>New-Alias -Name w -Value Get-WmiObject -Description “quick wmi Alias” -Option ReadOnly
C:\PS> Get-Alias -Name w | Format-List *
Description
———–
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.
RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113352
Set-Alias
Get-Alias
Export-Alias
Import-Alias