Export-Alias

Export 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]

Key
   -path string
       The path to the file where the alias information will be stored.

   -name string
       The name(s) of the aliases to export.
       Separate multiple names with commas, (default=all aliases)
       
   -passThru 
        Pass the object created by this cmdlet along the pipeline.
        
   -as ExportAliasFormat
        Format output as comma-separated (CSV) or (Script).

    -append
        Append output to the specified file, rather than overwrite.
        
    -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.
        
    -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.
        
   -whatIf
       Describe what would happen if you executed the command without actually
       executing the command.
       
   -confirm
       Prompt for confirmation before executing the command.
 
   CommonParameters:
        -Verbose, -Debug,-ErrorAction,-ErrorVariable, -OutVariable.

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

"Be the change you want to see in the world" - Mohandas Gandhi

Related:

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



Back to the Top

Simon Sheppard
SS64.com