Export (0) Print
Expand All

New-Alias

Updated: May 8, 2014

Applies To: Windows PowerShell 4.0

New-Alias

Creates a new alias.

Aliases

The following abbreviations are aliases for this cmdlet:

  • nal

Syntax

Parameter Set: Default
New-Alias [-Name] <String> [-Value] <String> [-Description <String> ] [-Force] [-Option <ScopedItemOptions> ] [-PassThru] [-Scope <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed 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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Force

If set, act like set-alias if the alias named already exists.


Aliases

none

Required?

false

Position?

named

Default Value

none

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.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-Option<ScopedItemOptions>

Sets the value of the Options property of the alias.

Valid values 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".


Aliases

none

Required?

false

Position?

named

Default Value

"None"

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru

Returns an object representing the new alias. By default, this cmdlet does not generate any output.


Aliases

none

Required?

false

Position?

named

Default Value

False

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.


Aliases

none

Required?

false

Position?

named

Default Value

Local

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Value<String>

Specifies the name of the cmdlet or command element that is being aliased.


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

    You cannot pipe input to this cmdlet.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • 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.

Examples

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

This command creates an alias named "list" to represent the Get-ChildItem cmdlet.


PS C:\> new-alias list get-childitem

-------------------------- EXAMPLE 2 --------------------------

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.


PS C:\> new-alias -name w -value get-wmiobject -description "quick wmi alias" -option ReadOnly
PS C:\>get-alias -name w | format-list *

Related topics



Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft