< Back
New-Alias
Post
NAME New-Alias
SYNOPSIS
Creates a new alias.
SYNTAX
New-Alias [-Name] <String> [-Value] <String> [-Confirm] [-Description <String>] [-Force] [-Option {None | ReadOnly | Constant | Private | AllScope
| Unspecified}] [-PassThru] [-Scope <String>] [-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
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-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 None
Accept pipeline input? False
Accept wildcard characters? false
-Force [<SwitchParameter>]
Indicates that the cmdlet acts like Set-Alias if the alias named already exists.
Required? false
Position? named
Default value False
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? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Option <ScopedItemOptions>
Specifies that the cmdlet sets the value of the Options property of the alias. The acceptable values for this parameter are:
- None. Sets no options. (None is the default.) - ReadOnly. Can be deleted. Cannot be not changed, except by using the Force parameter. -
Constant. 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.
To see the Options * * property of all aliases in the session, type `Get-Alias | Format-Table -Property name, options -autosize`.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Scope <String>
Specifies the scope of the new alias. The acceptable values for this parameter are:
- Global
- Local
- Script
- 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 None
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? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
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 (http://go.microsoft.com/fwlink/?LinkID=113216).
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: Create an alias for a cmdlet
PS C:\\>New-Alias -Name "List" Get-ChildItem
This command creates an alias named List to represent the Get-ChildItem cmdlet.
Example 2: Create a read-only alias for a cmdlet
PS C:\\>New-Alias -Name "W" -Value Get-WmiObject -Description "quick wmi alias" -Option ReadOnly
PS C:\\>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.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=821831
Export-Alias
Get-Alias
Import-Alias
Set-Alias
SYNOPSIS
Creates a new alias.
SYNTAX
New-Alias [-Name] <String> [-Value] <String> [-Confirm] [-Description <String>] [-Force] [-Option {None | ReadOnly | Constant | Private | AllScope
| Unspecified}] [-PassThru] [-Scope <String>] [-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
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-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 None
Accept pipeline input? False
Accept wildcard characters? false
-Force [<SwitchParameter>]
Indicates that the cmdlet acts like Set-Alias if the alias named already exists.
Required? false
Position? named
Default value False
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? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Option <ScopedItemOptions>
Specifies that the cmdlet sets the value of the Options property of the alias. The acceptable values for this parameter are:
- None. Sets no options. (None is the default.) - ReadOnly. Can be deleted. Cannot be not changed, except by using the Force parameter. -
Constant. 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.
To see the Options * * property of all aliases in the session, type `Get-Alias | Format-Table -Property name, options -autosize`.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Scope <String>
Specifies the scope of the new alias. The acceptable values for this parameter are:
- Global
- Local
- Script
- 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 None
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? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
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 (http://go.microsoft.com/fwlink/?LinkID=113216).
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: Create an alias for a cmdlet
PS C:\\>New-Alias -Name "List" Get-ChildItem
This command creates an alias named List to represent the Get-ChildItem cmdlet.
Example 2: Create a read-only alias for a cmdlet
PS C:\\>New-Alias -Name "W" -Value Get-WmiObject -Description "quick wmi alias" -Option ReadOnly
PS C:\\>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.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=821831
Export-Alias
Get-Alias
Import-Alias
Set-Alias