Export-Alias

Export information about currently-defined aliases to a file.

Syntax
      Export-Alias [-path] string  [[-name] string[]]
         [-as {Csv | Script}] [-append] [-description string]
            [-scope string] [-force]  [-passThru] [-noClobber]
               [-whatIf] [-confirm] [CommonParameters]
Key
   -path string
       The path to the file where the alias information will be stored.
       Wildcards are permitted, but the resulting path value must resolve to a
       single file name. This parameter is required.

   -name string
       The name(s) of the aliases to export.
       Separate multiple names with commas, (default=all aliases)
       By default, Export-Alias exports all aliases in the session or scope.
       
   -passThru 
       Pass the object created by this cmdlet along the pipeline.
        
   -as ExportAliasFormat
       Format output as comma-separated (CSV) or (Script).
       Script will create a Set-Alias command for each exported alias. If the
       output file is named with a .ps1 filename extension, it can be run
       as a script to add the aliases to any session.

   -append
       Append output to the specified file, rather than overwrite.
        
   -description string
       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.
        
   -scope string
       Either a named scope: "global", "local", or "script"; or a number
       to indicate the scope level. Scope = 0 = current scope
       Increasing the scope value by 1 will increate the scope to include the
       parent scope of the current scope. 
        
   -noClobber
       Do not overwrite an existing file, -Append will take precendence over -NoClobber.
        
   -force
       Override the read-only attribute on the output file.
       By default, Export-Alias will overwrite files without warning, unless the
       read-only or hidden attribute is set or -NoClobber is used.
       The -NoClobber parameter takes precedence over -Force when both are used in a command.

       The Force parameter cannot force Export-Alias to overwrite files with the hidden attribute.

   -whatIf
       Describe what would happen if you executed the command without actually
       executing the command.
       
   -confirm
       Prompt for confirmation before executing the command.

Standard Aliases for Export-Alias: epal

Header information output by Export-Alias, each is preceded by the # comment symbol:
Alias File, Exported by, Date/Time and Machine.

The -as Script output is in the format of a set-alias command.

Examples

Export alias information to alias.txt formatted as a series of set-alias commands:

PS C:> export-alias -path alias.txt -as script

Append the aliases in the current session to Alias.csv, use -Force to append to any existing Alias.csv file, even if it has the read-only attribute set:

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

“Be the change you want to see in the world” ~ Mohandas Gandhi

Related PowerShell Cmdlets

import-alias - Import an alias list from a file.
get-alias - Return alias names for Cmdlets.
new-alias - Create a new Cmdlet-alias pairing.
set-alias - Map an alias to a Cmdlet.
Equivalent bash commands: useradd - Create new user accounts.


 
Copyright © 1999-2024 SS64.com
Some rights reserved