Imports an alias list from a file.

Syntax

  Copy Code
Import-Alias [-Path] <string> [-Force] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

Description

The Import-Alias cmdlet imports an alias list from a file.

Parameters

-Force

Allows the cmdlet to import an alias that is already defined and is read only. You can use the following command to display information about the currently-defined aliases:

get-alias | Select-Object name,Options

The value of the Options property will include "ReadOnly" if the corresponding alias is read only.

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru

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

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Path <string>

Specifies the path to a file that includes exported alias information. Wildcards are allowed but they must resolve to a single name.

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Scope <string>

Specifies the scope into which the aliases are imported. 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

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before executing the command.

Required?

false

Position?

named

Default Value

none

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

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This command supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, OutBuffer, OutVariable, WarningAction, and WarningVariable. For more information, see about_CommonParameters.

Inputs and Outputs

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

Inputs

System.String

You can pipe a string that contains a path to Import-Alias.

Outputs

None or System.Management.Automation.AliasInfo

When you use the Passthru parameter, Import-Alias returns a System.Management.Automation.AliasInfo object that represents the alias. Otherwise, this cmdlet does not generate any output.

Example 1

  Copy Code
C:\PS>import-alias test.txt

Description

-----------

This command imports alias information from a file named test.txt.

See Also