Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmdlet documentation #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions docs/Compare-Text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
external help file: Microsoft.PowerShell.TextUtility.dll-Help.xml
Module Name: Microsoft.PowerShell.TextUtility
online version:
ms.date: 08/29/2024
schema: 2.0.0
---

# Compare-Text

## SYNOPSIS

This cmdlet compares two text strings using diff-match-patch.

## SYNTAX

```
Compare-Text [-LeftText] <String> [-RightText] <String> [-View <CompareTextView>]
[<CommonParameters>]
```

## DESCRIPTION

This cmdlet compares two text strings using the **diff-match-patch** library.

The [diff-match-patch](https://github.com/google/diff-match-patch) library provides methods used for
synchronizing plain text, similar to the diff functions of `git`.

## EXAMPLES

### Example 1 - Compare two multiline strings

This example shows how to compare two multiline strings using the `Compare-Text` cmdlet. The cmdlet
uses ANSI escape codes to highlight the differences between the two strings.

```powershell
$leftText = @("This is some", "example text.") -join [Environment]::NewLine
$rightText = @(" This is other", "example text used!") -join [Environment]::NewLine
Compare-Text -LeftText $leftText -RightText $rightText -View SideBySide
```

```Output
1 | This is some | This is other
2 | example text. | example text…
```

This example output shows the differences in red with strikethrough characters on the left and
additions in green on the right.

## PARAMETERS

### -LeftText

The source string to be compared. This can be a single line or a multiline string.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -RightText

The difference string to be compared. This can be a single line or a multiline string.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -View

The view mode to display the comparison. The possible values are:

- `Inline` - (Default) Shows the differences, side-by-side on the same line.
- `SideBySide` - Shows the differences, side-by-side in separate columns.

```yaml
Type: Microsoft.PowerShell.TextUtility.CompareTextView
Parameter Sets: (All)
Aliases:
Accepted values: Inline, SideBySide

Required: False
Position: Named
Default value: None
Accept pipeline input: False
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](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### None

## OUTPUTS

### Microsoft.PowerShell.TextUtility.CompareTextDiff

## NOTES

## RELATED LINKS
120 changes: 120 additions & 0 deletions docs/ConvertFrom-Base64.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
external help file: Microsoft.PowerShell.TextUtility.dll-Help.xml
Module Name: Microsoft.PowerShell.TextUtility
online version:
ms.date: 08/29/2024
schema: 2.0.0
---

# ConvertFrom-Base64

## SYNOPSIS

Converts a Base64-encoded string back to its original form.

## SYNTAX

```
ConvertFrom-Base64 [-EncodedText] <String> [-AsByteArray] [<CommonParameters>]
```

## DESCRIPTION

The command converts a Base64-encoded string back to its original form. The original form can be a
string or any arbitrary binary data.

## EXAMPLES

### Example 1 - Convert a Base64-encoded string to its original form

```powershell
ConvertFrom-Base64 -EncodedText "SGVsbG8gV29ybGQh"
```

```output
Hello World!
```

### Example 1 - Convert a Base64-encoded string to its original form as a byte array

```powershell
ConvertFrom-Base64 -EncodedText "SGVsbG8gV29ybGQh" -AsByteArray
```

```output
72
101
108
108
111
32
87
111
114
108
100
33
```

## PARAMETERS

### -AsByteArray

Returns the converted output as an array of bytes. This is useful when the original form is binary
data.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -EncodedText

The Base64-encoded string to convert back to its original form.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
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](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### System.String

## OUTPUTS

### System.String

By default, this command returns the converted data as a string.

### System.Byte

When you use the **AsByteArray** parameter, this command returns the converted data as an array of
bytes.

## NOTES

## RELATED LINKS

[ConvertTo-Base64](ConvertTo-Base64.md)
Loading