Export-Alias

 

Additional Resources for Export-Alias

 

Saving Windows PowerShell Aliases

http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/export-alias.mspx

 

 

SYNOPSIS

Exports information about currently-defined aliases to a file.

 

SYNTAX

Export-Alias [-path] <string> [[-name] <string[]>] [-passThru] [-as {<Csv> | <Script>}] [-append] [-description <string>] [-scope <string>] [-force] [-noClobber] [-whatIf] [-confirm] [<CommonParameters>]

 

DETAILED DESCRIPTION

Exports information about currently-defined aliases within a specified namespace scope to a file. If the output file specified does not exist, the cmdlet will create it. It can export the alias information to comma-separated value (CSV) format or script (Script) format. Both formats include the following header information preceded by the # comment symbol: Alias File, Exported by, Date/Time and Machine.

 

The CSV format includes the name of the alias, the name of the corresponding cmdlet, the description of the alias if there is one, and the scope. The Script format includes the same information, but provides it as a set-alias command with the alias information provided as the value of the parameters to Set-Alias.

 

PARAMETERS

 

-path <string>

Specifies the path to the file in which to store alias information. You can use wildcards, but the resulting path value must resolve to a single file name.

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

true

 

-name <string[]>

Specifies the names of the aliases to export. To enter multiple alias names, separate them by using commas. If you do not specify an alias name or names, the cmdlet exports information about all of the current aliases.

 

Required?

false

Position?

2

Default value

*

Accept pipeline input?  

true (ByPropertyName)

Accept wildcard characters? 

true

 

-passThru <SwitchParameter>

Indicates that the object created by this cmdlet should be passed along the pipeline. By default, this cmdlet does not pass any objects along the pipeline.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-as <ExportAliasFormat>

Determines whether the aliases are output in comma-separated value (CSV) format or in script (Script) format. The following lists the acceptable values for this parameter:

 

·          Csv

·          Script

 

Required?

false

Position?

named

Default value

"CSV"

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-append <SwitchParameter>

Appends the output to the specified file, rather than overwriting the existing contents of that file.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-description <string>

Enables you to add a description to the exported file. The description appears at the top of the file, following the header information. It is preceded by a # symbol.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-scope <string>

Specifies the scope from which the aliases should be exported. This can be a named scope like "global", "local", or "script"; or it can be a number that indicates the level of scope to include in the export. A scope value of 0 indicates the current scope and increasing the value by 1 indicates that the scope should be the parent scope of the current scope.

 

Required?

false

Position?

named

Default value

All locally visible aliases

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-force <SwitchParameter>

Forces the cmdlet to clear the read-only attribute of the output file if it is set. After the command is complete, the read-only attribute will be reset if possible.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-noClobber <SwitchParameter>

Ensures that the cmdlet cannot overwrite an existing file. If the NoClobber parameter is not specified, Export-Alias overwrites the specified export file without warning. If both Append and NoClobber are specified, the output is appended to the existing file.

 

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

System.Management.Automation.AliasInfo

 

RETURN TYPE

System.Management.Automation.AliasInfo

 

NOTES

 

For more information, type "Get-Help Export-Alias  -detailed". For technical information, type "Get-Help Export-Alias -full".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

Export-Alias does not support exporting aliases to a non-file system path.

 

EXAMPLE 1

 

export-alias -path alias.txt

notepad alias.txt

 

This command exports current alias information to a file named alias.txt in the current directory. It then opens the result in Notepad.

 

EXAMPLE 2

 

export-alias -path alias.txt -noclobber

 

This command attempts to export current alias information to a file named alias.txt. Because the NoClobber parameter is specified, the command will not complete successfully if a file named alias.txt already exists in the current directory.

 

EXAMPLE 3

 

export-alias -path alias.txt -append -description "Appended Alias Info"

 

This command exports current alias information to a file named alias.txt. It includes a description in the header comment of the file and appends the exported information if the file named alias.txt exists and has content.

 

EXAMPLE 4

 

export-alias -path alias.txt -as script

notepad alias.txt

 

This command exports current alias information to a file named alias.txt. It overwrites any previous contents in that file if it exists. The alias information is exported as a series of commands that use the Set-Alias cmdlet. In the second line, the command opens the resulting exported file using Notepad.

 

RELATED LINKS

Import-Alias

Get-Alias

New-Alias

Set-Alias