Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ When multiple processes are passed into `Wait-Process`, the cmdlet waits for all
before returning. With this parameter, the cmdlet returns when any of the processes exits. The
remaining processes continue to run.

This parameter was added in PowerShell 7.4.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Expand Down Expand Up @@ -167,6 +169,8 @@ Accept wildcard characters: False
By default, this cmdlet doesn't output anything. With this parameter, the cmdlet returns objects
representing the processes that were waited on.

This parameter was added in PowerShell 7.4.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Expand Down
66 changes: 57 additions & 9 deletions reference/7.4/Microsoft.PowerShell.Utility/Get-Unique.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 01/23/2023
ms.date: 08/18/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-unique?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-Unique
Expand All @@ -18,22 +18,22 @@ Returns unique items from a sorted list.
### AsString (Default)

```
Get-Unique [-InputObject <PSObject>] [-AsString] [<CommonParameters>]
Get-Unique [-InputObject <PSObject>] [-AsString] [-CaseInsensitive] [<CommonParameters>]
```

### UniqueByType

```
Get-Unique [-InputObject <PSObject>] [-OnType] [<CommonParameters>]
Get-Unique [-InputObject <PSObject>] [-OnType] [-CaseInsensitive] [<CommonParameters>]
```

## DESCRIPTION

The `Get-Unique` cmdlet compares each item in a sorted list to the next item, eliminates duplicates,
and returns only one instance of each item. The list must be sorted for the cmdlet to work properly.

`Get-Unique` is case-sensitive. As a result, strings that differ only in character casing are
considered to be unique.
By default, `Get-Unique` is case-sensitive. As a result, strings that differ only in character
casing are considered to be unique.

## EXAMPLES

Expand Down Expand Up @@ -110,6 +110,34 @@ The **AsString** parameter tells `Get-Unique` to treat the **ProcessName** value
Without this parameter, `Get-Unique` treats the **ProcessName** values as objects and returns only
one instance of the object, that is, the first process name in the list.

### Example 5: Use case-sensitive comparisons to get unique strings

This example uses case-insensitive comparisons to get unique strings from an array of strings.

```powershell
"aa", "Aa", "Bb", "bb", "aa" | Sort-Object -CaseSensitive | Get-Unique
```

```Output
aa
Aa
bb
Bb
```

### Example 6: Use case-insensitive comparisons to get unique strings

This example uses case-insensitive comparisons to get unique strings from an array of strings.

```powershell
"aa", "Aa", "Bb", "bb", "aa" | Sort-Object | Get-Unique -CaseInsensitive
```

```Output
aa
Bb
```

## PARAMETERS

### -AsString
Expand All @@ -126,7 +154,26 @@ Aliases:

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

### -CaseInsensitive

By default, `Get-Unique` is case-sensitive. When you use this parameter, the cmdlet uses
case-insensitive comparisons.

This parameter was added in PowerShell 7.4.

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

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
Expand All @@ -136,9 +183,9 @@ Accept wildcard characters: False
Specifies input for `Get-Unique`. Enter a variable that contains the objects or type a command or
expression that gets the objects.

This cmdlet treats the input submitted by using **InputObject** as a collection. it does not
This cmdlet treats the input submitted using **InputObject** as a collection. It doesn't
enumerate individual items in the collection. Because the collection is a single item, input
submitted by using **InputObject** is always returned unchanged.
submitted using **InputObject** is always returned unchanged.

```yaml
Type: System.Management.Automation.PSObject
Expand Down Expand Up @@ -172,7 +219,8 @@ Accept wildcard characters: False

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).
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down
67 changes: 52 additions & 15 deletions reference/7.4/Microsoft.PowerShell.Utility/Select-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 06/01/2023
ms.date: 08/18/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Select-Object
Expand All @@ -19,27 +19,30 @@ Selects objects or object properties.

```
Select-Object [-InputObject <PSObject>] [[-Property] <Object[]>] [-ExcludeProperty <String[]>]
[-ExpandProperty <String>] [-Unique] [-Last <Int32>] [-First <Int32>] [-Skip <Int32>] [-Wait]
[<CommonParameters>]
[-ExpandProperty <String>] [-Unique] [-CaseInsensitive] [-Last <Int32>] [-First <Int32>] [-Skip <Int32>]
[-Wait] [<CommonParameters>]
```

### SkipLastParameter

```
Select-Object [-InputObject <PSObject>] [[-Property] <Object[]>] [-ExcludeProperty <String[]>]
[-ExpandProperty <String>] [-Unique] [-Skip <Int32>] [-SkipLast <Int32>] [<CommonParameters>]
[-ExpandProperty <String>] [-Unique] [-CaseInsensitive] [-Skip <Int32>] [-SkipLast <Int32>]
[<CommonParameters>]
```

### IndexParameter

```
Select-Object [-InputObject <PSObject>] [-Unique] [-Wait] [-Index <Int32[]>] [<CommonParameters>]
Select-Object [-InputObject <PSObject>] [-Unique] [-CaseInsensitive] [-Wait] [-Index <Int32[]>]
[<CommonParameters>]
```

### SkipIndexParameter

```
Select-Object [-InputObject <PSObject>] [-Unique] [-SkipIndex <Int32[]>] [<CommonParameters>]
Select-Object [-InputObject <PSObject>] [-Unique] [-CaseInsensitive] [-SkipIndex <Int32[]>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -139,13 +142,14 @@ This example uses the **Unique** parameter of `Select-Object` to get unique char
of characters.

```powershell
"a","b","c","a","a","a" | Select-Object -Unique
"a","b","c","a","A","a" | Select-Object -Unique
```

```Output
a
b
c
A
```

### Example 5: Using `-Unique` with other parameters
Expand All @@ -165,7 +169,20 @@ a
In this example, **First** selects `"a","a"` as the first 2 items in the array. **Unique** is
applied to `"a","a"` and returns `a` as the unique value.

### Example 6: Select newest and oldest events in the event log
### Example 6: Select unique strings using the `-CaseInsensitive` parameter

This example uses case-insensitive comparisons to get unique strings from an array of strings.

```powershell
"aa", "Aa", "Bb", "bb" | Select-Object -Unique -CaseInsensitive
```

```Output
aa
Bb
```

### Example 7: Select newest and oldest events in the event log

This example gets the first (newest) and last (oldest) events in the Windows PowerShell event log.

Expand All @@ -179,7 +196,7 @@ $a = Get-WinEvent -LogName "Windows PowerShell"
$a | Select-Object -Index 0, ($a.count - 1)
```

### Example 7: Select all but the first object
### Example 8: Select all but the first object

This example creates a new PSSession on each of the computers listed in the Servers.txt files,
except for the first one.
Expand All @@ -191,7 +208,7 @@ of computers is set as the value of the **ComputerName** parameter of the `New-P
New-PSSession -ComputerName (Get-Content Servers.txt | Select-Object -Skip 1)
```

### Example 8: Rename files and select several to review
### Example 9: Rename files and select several to review

This example adds a "-ro" suffix to the base names of text files that have the read-only attribute
and then displays the first five files so the user can see a sample of the effect.
Expand All @@ -211,7 +228,7 @@ Get-ChildItem *.txt -ReadOnly |
Select-Object -First 5 -Wait
```

### Example 9: Show the intricacies of the -ExpandProperty parameter
### Example 10: Show the intricacies of the -ExpandProperty parameter

This example shows the intricacies of the **ExpandProperty** parameter.

Expand Down Expand Up @@ -269,7 +286,7 @@ ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider pro
Name NoteProperty string Name=CustomObject
```

### Example 10: Create custom properties on objects
### Example 11: Create custom properties on objects

The following example demonstrates using `Select-Object` to add a custom property to any object.
When you specify a property name that doesn't exist, `Select-Object` creates that property as a
Expand All @@ -287,7 +304,7 @@ MyCustomProperty
New Custom Property
```

### Example 11: Create calculated properties for each InputObject
### Example 12: Create calculated properties for each InputObject

This example demonstrates using `Select-Object` to add calculated properties to your input. Passing
a **ScriptBlock** to the **Property** parameter causes `Select-Object` to evaluate the expression on
Expand Down Expand Up @@ -334,7 +351,7 @@ Diagnostics.Format.ps1xml 4.955078125 223
DotNetTypes.format.ps1xml 134.9833984375 223
```

### Example 12: Select hashtable keys without using calculated properties
### Example 13: Select hashtable keys without using calculated properties

Beginning in PowerShell 6, `Select-Object` supports selecting the keys of **hashtable** input as
properties. The following example selects the `weight` and `name` keys on an input hashtable and
Expand All @@ -352,6 +369,25 @@ a 7

## PARAMETERS

### -CaseInsensitive

By default, when you use the **Unique** parameter the cmdlet uses case-sensitive comparisons. When
you use this parameter, the cmdlet uses case-insensitive comparisons.

This parameter was added in PowerShell 7.4.

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

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

### -ExcludeProperty

Specifies the properties that this cmdlet excludes from the operation. Wildcards are permitted.
Expand Down Expand Up @@ -574,7 +610,8 @@ member of the subset should be selected.
**Unique** selects values _after_ other filtering parameters are applied.

This parameter is case-sensitive. As a result, strings that differ only in character casing are
considered to be unique.
considered to be unique. Add the **CaseInsensitive** parameter to perform case-insensitive
comparisons.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand Down