This is the built-in help made by Microsoft for the command 'Export-Alias', in PowerShell version 2 - as retrieved from
Windows version 'Microsoft® Windows Vista™ Ultimate ' 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.
Exports information about currently defined aliases to a file.
Export-Alias [-Path] <string> [[-Name] <string[]>] [-Append] [-As {Csv | Script}] [-Description <string>] [-Force] [-NoClobber] [-PassThru] [-Sco
pe <string>] [-Confirm] [-WhatIf] [<CommonParameters>]
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 comma
nds that you can add to a session or to a Windows PowerShell profile.
<
Online version: http://go.microsoft.com/fwlink/?LinkID=113296
Import-Alias
Get-Alias
New-Alias
Set-Alias
<
-------------------------- EXAMPLE 1 --------------------------
C:\PS>export-alias -path alias.csv
Description
-----------
This command exports current alias information to a file named Alias.csv in the current directory.
-------------------------- EXAMPLE 2 --------------------------
C:\PS>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 --------------------------
C:\PS>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 --------------------------
C:\PS>export-alias -path alias.ps1 -as script
C:\PS> add-content -path $profile -value (get-content alias.ps1)
C:\PS> $s = new-pssession -computername Server01
C:\PS> 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 th
at 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 $profi
le 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 pr
ofile. 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.