Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwheeler committed Jan 9, 2025
1 parent a21048a commit 718636c
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 156 deletions.
118 changes: 66 additions & 52 deletions reference/5.1/Microsoft.PowerShell.Utility/Export-Alias.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,27 @@ Exports information about currently defined aliases to a file.
### ByPath (Default)

```
Export-Alias [-Path] <String> [[-Name] <String[]>] [-PassThru] [-As <ExportAliasFormat>] [-Append] [-Force]
[-NoClobber] [-Description <String>] [-Scope <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Export-Alias [-Path] <String> [[-Name] <String[]>] [-PassThru] [-As <ExportAliasFormat>] [-Append]
[-Force] [-NoClobber] [-Description <String>] [-Scope <String>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### ByLiteralPath

```
Export-Alias -LiteralPath <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>]
```

## 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.
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` 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.

## EXAMPLES

Expand All @@ -54,7 +58,8 @@ Export-Alias -Path "alias.csv" -NoClobber

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.
Because the **NoClobber** parameter is specified, the command will fail if an Alias.csv file already
exists in the current directory.

### Example 3: Append aliases to a file

Expand All @@ -64,9 +69,11 @@ Export-Alias -Path "alias.csv" -Append -Description "Appended Aliases" -Force

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 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.
The command also uses the **Force** parameter to overwrite any existing Alias.csv files, even if
they have the read-only attribute.

### Example 4: Export aliases as a script

Expand All @@ -79,23 +86,27 @@ Invoke-Command -Session $S -FilePath .\alias.ps1

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 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](../Microsoft.PowerShell.Core/About/about_Profiles.md).
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](../Microsoft.PowerShell.Core/About/about_Profiles.md).

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.
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.

## PARAMETERS

### -Append

Indicates that this cmdlet appends the output to the specified file, rather than overwriting the existing contents of that file.
Indicates that this cmdlet appends the output to the specified file, rather than overwriting the
existing contents of that file.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand All @@ -115,11 +126,9 @@ Specifies 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.
- 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.

```yaml
Type: Microsoft.PowerShell.Commands.ExportAliasFormat
Expand All @@ -136,8 +145,8 @@ Accept wildcard characters: False

### -Description

Specifies the description of the exported file.
The description appears as a comment at the top of the file, following the header information.
Specifies the description of the exported file. The description appears as a comment at the top of
the file, following the header information.

```yaml
Type: System.String
Expand All @@ -157,8 +166,9 @@ Forces 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.
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.

Expand All @@ -176,11 +186,10 @@ Accept wildcard characters: False

### -LiteralPath

Specifies 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.
Specifies 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.

```yaml
Type: System.String
Expand All @@ -196,8 +205,7 @@ Accept wildcard characters: False

### -Name

Specifies the names as an array of the aliases to export.
Wildcards are permitted.
Specifies 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.

Expand All @@ -215,12 +223,14 @@ Accept wildcard characters: True

### -NoClobber

Indicates that this cmdlet prevents `Export-Alias` from overwriting any files, even if the **Force** parameter is used in the command.
Indicates 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.
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.
**NoClobber** does not prevent the **Append** parameter from adding content to an existing file.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand All @@ -236,8 +246,8 @@ Accept wildcard characters: False

### -PassThru

Returns an object representing the item with which you are working.
By default, this cmdlet does not generate any output.
Returns an object representing the item with which you are working. By default, this cmdlet does not
generate any output.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand All @@ -253,8 +263,8 @@ Accept wildcard characters: False

### -Path

Specifies the path to the output file.
Wildcards are permitted, but the resulting path value must resolve to a single file name.
Specifies the path to the output file. Wildcards are permitted, but the resulting path value must
resolve to a single file name.

```yaml
Type: System.String
Expand All @@ -270,16 +280,17 @@ Accept wildcard characters: True

### -Scope

Specifies the scope from which the aliases should be exported.
The acceptable values for this parameter are:
Specifies 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)
- `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](../Microsoft.PowerShell.Core/About/about_Scopes.md).
The default value is `Local`. For more information, see
[about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).

```yaml
Type: System.String
Expand Down Expand Up @@ -328,7 +339,10 @@ Accept wildcard characters: False

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down
Loading

0 comments on commit 718636c

Please sign in to comment.