PowerShell Logo Small

Export-Alias



This is the built-in help made by Microsoft for the command 'Export-Alias', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Exports information about currently defined aliases to a file.

SYNTAX


Export-Alias [-Path] <String> [[-Name] [<String[]>]] [-Append] [-As {Csv | Script}] [-Description [<String>]] [-Force] [-InformationAction {SilentlyContinue | Stop |
Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-NoClobber] [-PassThru] [-Scope [<String>]] [-Confirm] [-WhatIf] [<CommonParameters>]
Export-Alias [[-Name] [<String[]>]] [-Append] [-As {Csv | Script}] [-Description [<String>]] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire |
Ignore | Suspend}] [-InformationVariable [<System.String>]] [-NoClobber] [-PassThru] [-Scope [<String>]] -LiteralPath <String> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Export-Alias cmdlet exports the aliases in the current session to a file. If the output file does not exist, the cmdlet will create it.


Export-Alias can export the aliases in a particular scope or all scopes, it can generate the data in CSV format or as a series of Set-Alias commands that you can add to a
session or to a Windows PowerShell profile.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293955
Get-Alias
Import-Alias
New-Alias
Set-Alias

REMARKS

<

Examples


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

PS C:\>export-alias -path alias.csv



Description

-----------

This command exports current alias information to a file named Alias.csv in the current directory.










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

PS C:\>export-alias -path alias.csv -noclobber



Description

-----------

This command exports the aliases in the current session to an Alias.csv file.

Because the NoClobber parameter is specified, the command will fail if an Alias.csv file already exists in the current directory.










-------------------------- EXAMPLE 3 --------------------------

PS C:\>export-alias -path alias.csv -append -description "Appended Aliases" -force



Description

-----------

This command appends the aliases in the current session to the Alias.csv file.

The command uses the Description parameter to add a description to the comments at the top of the file.

The command also uses the Force parameter to overwrite any existing Alias.csv files, even if they have the read-only attribute.










-------------------------- EXAMPLE 4 --------------------------

PS C:\>export-alias -path alias.ps1 -as script
PS C:\> add-content -path $profile -value (get-content alias.ps1)
PS C:\> $s = new-pssession -computername Server01
PS C:\> invoke-command -session $s -filepath .\alias.ps1



Description

-----------

This example shows how to use the script file format that Export-Alias generates.

The first command exports the aliases in the session to the Alias.ps1 file. It uses the As parameter with a value of Script to generate a file that contains a Set-Alias
command for each alias.

The second command adds the aliases in the Alias.ps1 file to the CurrentUser-CurrentHost profile. (The path to the profile is saved in the $profile variable.) The command
uses the Get-Content cmdlet to get the aliases from the Alias.ps1 file and the Add-Content cmdlet to add them to the profile. For more information, see about_Profiles.

The third and fourth commands add the aliases in the Alias.ps1 file to a remote session on the Server01 computer. The third command uses the New-PSSession cmdlet to create
the session. The fourth command uses the FilePath parameter of the Invoke-Command cmdlet to run the Alias.ps1 file in the new session.