New-Alias
Additional Resources for New-Alias |
Creating a New Windows PowerShell Alias http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/new-alias.mspx
|
SYNOPSIS
Creates a new alias.
SYNTAX
New-Alias [-name] <string> [-value] <string> [-description <string>] [-option {<None> | <ReadOnly> | <Constant> | <Private> | <AllScope>}] [-passThru] [-scope <string>] [-force] [-whatIf] [-confirm] [<CommonParameters>]
DETAILED DESCRIPTION
Creates a new alias. This alias name will be added to the list for the 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
-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 |
-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 |
-description <string>
Specifies a description of the alias. You can type any string. If the description includes spaces, enclose it quotation marks.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
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.
The following lists the acceptable values for this parameter:
· None
· ReadOnly
· Constant
· Private
· AllScope
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-passThru <SwitchParameter>
Passes the object created by this cmdlet through the pipeline. By default, this cmdlet does not pass any objects through the pipeline.
Required? |
false |
Position? |
named |
Default value |
False |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-scope <string>
The scope from which the aliases should be exported. This can be a named scope: "global", "local", or "script", or it can be a number relative to the current scope (from 0 through the number of scopes where 0 is the current scope and 1 is its parent).
Required? |
false |
Position? |
named |
Default value |
local |
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 |
False |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
-whatIf
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 |
-confirm
Prompts you for confirmation before 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, and -OutVariable. For more information, type, "get-help about_commonparameters".
INPUT TYPE
String
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
new-alias list get-childitem
This command creates an alias named 'list' to represent the Get-ChildItemcmdlet.
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-WMIObjectcmdlet. It creates a description, "quick wmi alias", for the alias and makes it read only. The last line of the command uses Get-Aliasto get the new alias and pipes it to Format-Listto display all of the information about it.
RELATED LINKS