CmdID / PowerShell / Cmdlets / Export
Export-Alias
Exports information about currently defined aliases to a file. PowerShell reference
From the PowerShell reference
12 parameters
Alias epal
What it does
Exports information about currently defined aliases to a file. 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 PowerShell profile.
Export-Alias [-Path] <String> [[-Name] <String[]>] [-PassThru] [-As <ExportAliasFormat>] [-Append] [-Force] [-NoClobber] [-Description <String>] [-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>]Export-Alias -LiteralPath <String> [[-Name] <String[]>] [-PassThru] [-As <ExportAliasFormat>] [-Append] [-Force] [-NoClobber] [-Description <String>] [-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Export an alias
Export-Alias -Path Alias.csvIdentifyExport an alias unless the export file already exists
Export-Alias -Path Alias.csv -NoClobberIdentifyAppend aliases to a file
Export-Alias -Path Alias.csv -Append -Description "Appended Aliases" -ForceIdentifyExport aliases as a script
Export-Alias -Path Alias.ps1 -As Script
Add-Content -Path $PROFILE -Value (Get-Content Alias.ps1)
$S = New-PSSession -ComputerName Server01
Invoke-Command -Session $S -FilePath .\Alias.ps1IdentifyIts page in the reference: Export-Alias.
Parameters
-AppendIndicates that this cmdlet appends the output to the specified file, rather than overwriting the existing contents of that file.-AsSpecifies the output format. CSV is the default. The acceptable values for this parameter are:
- CSV. Comma-separated value (CSV) format.
- Script. Creates a Set-Alias command for each exported alias. If you name the output file with a
.ps1 file name extension, you can run it as a script to add the aliases to any session.-DescriptionSpecifies the description of the exported file. The description appears as a comment at the top of the file, following the header information.-ForceForces the command to run without asking for user confirmation.
Overwrites the output file, even if the read-only attribute is set on the file.
By default, Export-Alias overwrites files without warning, unless the read-only or hidden attribute is set or the NoClobber parameter is used in the command. The NoClobber parameter takes precedence over the Force parameter when both are used in a command.
The Force parameter cannot force Export-Alias to overwrite files with the hidden attribute.-LiteralPathSpecifies the path to the output file. Unlike Path, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.-NameSpecifies the names as an array of the aliases to export. Wildcards are permitted.
By default, Export-Alias exports all aliases in the session or scope.-NoClobberIndicates that this cmdlet prevents Export-Alias from overwriting any files, even if the Force parameter is used in the command.
If the NoClobber parameter is omitted, Export-Alias will overwrite an existing file without warning, unless the read-only attribute is set on the file. NoClobber takes precedence over the Force parameter, which permits Export-Alias to overwrite a file with the read-only attribute.
NoClobber does not prevent the Append parameter from adding content to an existing file.-PassThruReturns an object representing the item with which you are working. By default, this cmdlet does not generate any output.-PathSpecifies the path to the output file. Wildcards are permitted, but the resulting path value must resolve to a single file name.-ScopeSpecifies the scope from which the aliases should be exported. The acceptable values for this parameter are:
- Global
- Local
- Script
- A number relative to the current scope (0 through the number of scopes where 0 is the current
scope and 1 is its parent)
The default value is Local. For more information, see about_Scopes.-ConfirmPrompts you for confirmation before running the cmdlet.-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.