From e5e064bb795a8c95547930551a0a96cfcda3122f Mon Sep 17 00:00:00 2001 From: chasewilson Date: Fri, 15 Oct 2021 10:02:15 -0700 Subject: [PATCH 1/3] Automatically committed changes. --- .../Select-Object.md | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md b/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md index bfe059efc0f3..e627e98f12aa 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md @@ -141,7 +141,21 @@ b c ``` -### Example 5: Select newest and oldest events in the event log +## Example 5: Using Unique with other Select-Object parameters + +**Unique** gets unique values after other `Select-Object` parameters are applied. For example, +if you use the **First** parameter to select the first number of items in array, **Unique** will +only be applied to the selected values and not the entire array. + +```powershell +"a","a","b","c" | Select-Object -First 2 -Unique +``` + +```Output +a +``` + +### Example 6: 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. @@ -155,7 +169,7 @@ $a = Get-EventLog -LogName "Windows PowerShell" $a | Select-Object -Index 0, ($A.count - 1) ``` -### Example 6: Select all but the first object +### Example 7: 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. @@ -167,7 +181,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 7: Rename files and select several to review +### Example 8: 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. @@ -187,7 +201,7 @@ Get-ChildItem *.txt -ReadOnly | Select-Object -First 5 -Wait ``` -### Example 8: Demonstrate the intricacies of the -ExpandProperty parameter +### Example 9: Demonstrate the intricacies of the -ExpandProperty parameter This example demonstrates the intricacies of the **ExpandProperty** parameter. @@ -245,7 +259,7 @@ ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider pro Name NoteProperty string Name=CustomObject ``` -### Example 9: Create custom properties on objects +### Example 10: 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 does not exist, `Select-Object` creates that property as a @@ -263,7 +277,7 @@ MyCustomProperty New Custom Property ``` -### Example 10: Create calculated properties for each InputObject +### Example 11: 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 @@ -505,6 +519,8 @@ Accept wildcard characters: False Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will 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. From b66b7e708b860ff3b2ad8e8b768bb087e2b9acd7 Mon Sep 17 00:00:00 2001 From: Chase Wilson <31453523+chasewilson@users.noreply.github.com> Date: Fri, 15 Oct 2021 10:31:30 -0700 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Sean Wheeler --- .../5.1/Microsoft.PowerShell.Utility/Select-Object.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md b/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md index e627e98f12aa..1d132f91569c 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md @@ -141,11 +141,11 @@ b c ``` -## Example 5: Using Unique with other Select-Object parameters +### Example 5: Using `-Unique` with other parameters -**Unique** gets unique values after other `Select-Object` parameters are applied. For example, -if you use the **First** parameter to select the first number of items in array, **Unique** will -only be applied to the selected values and not the entire array. +The **Unique** parameter filters values after other `Select-Object` parameters are applied. For +example, if you use the **First** parameter to select the first number of items in an array, **Unique** +is only applied to the selected values and not the entire array. ```powershell "a","a","b","c" | Select-Object -First 2 -Unique From c33c3bff82a0a61942e78de25b839a09d958b97b Mon Sep 17 00:00:00 2001 From: chasewilson Date: Fri, 15 Oct 2021 10:40:07 -0700 Subject: [PATCH 3/3] Updates for PR feedback --- .../Select-Object.md | 5 ++- .../Select-Object.md | 33 +++++++++++++++---- .../Select-Object.md | 33 +++++++++++++++---- .../Select-Object.md | 33 +++++++++++++++---- 4 files changed, 82 insertions(+), 22 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md b/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md index 1d132f91569c..513142303a3b 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Select-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 09/25/2020 +ms.date: 10/15/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-object?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Select-Object @@ -155,6 +155,9 @@ is only applied to the selected values and not the entire array. 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 This example gets the first (newest) and last (oldest) events in the Windows PowerShell event log. diff --git a/reference/7.0/Microsoft.PowerShell.Utility/Select-Object.md b/reference/7.0/Microsoft.PowerShell.Utility/Select-Object.md index ba3606135db3..7c20f33f24cd 100644 --- a/reference/7.0/Microsoft.PowerShell.Utility/Select-Object.md +++ b/reference/7.0/Microsoft.PowerShell.Utility/Select-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 09/25/2020 +ms.date: 10/15/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 title: Select-Object @@ -147,7 +147,24 @@ b c ``` -### Example 5: Select newest and oldest events in the event log +### Example 5: Using `-Unique` with other parameters + +The **Unique** parameter filters values after other `Select-Object` parameters are applied. For +example, if you use the **First** parameter to select the first number of items in an array, **Unique** +is only applied to the selected values and not the entire array. + +```powershell +"a","a","b","c" | Select-Object -First 2 -Unique +``` + +```Output +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 This example gets the first (newest) and last (oldest) events in the Windows PowerShell event log. @@ -161,7 +178,7 @@ $a = Get-EventLog -LogName "Windows PowerShell" $a | Select-Object -Index 0, ($A.count - 1) ``` -### Example 6: Select all but the first object +### Example 7: 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. @@ -173,7 +190,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 7: Rename files and select several to review +### Example 8: 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. @@ -193,7 +210,7 @@ Get-ChildItem *.txt -ReadOnly | Select-Object -First 5 -Wait ``` -### Example 8: Demonstrate the intricacies of the -ExpandProperty parameter +### Example 9: Demonstrate the intricacies of the -ExpandProperty parameter This example demonstrates the intricacies of the **ExpandProperty** parameter. @@ -251,7 +268,7 @@ ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider pro Name NoteProperty string Name=CustomObject ``` -### Example 9: Create custom properties on objects +### Example 10: 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 does not exist, `Select-Object` creates that property as a @@ -269,7 +286,7 @@ MyCustomProperty New Custom Property ``` -### Example 10: Create calculated properties for each InputObject +### Example 11: 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 @@ -527,6 +544,8 @@ Accept wildcard characters: False Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will 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. diff --git a/reference/7.1/Microsoft.PowerShell.Utility/Select-Object.md b/reference/7.1/Microsoft.PowerShell.Utility/Select-Object.md index 3bfb6c3a3a1d..7dd28d72693e 100644 --- a/reference/7.1/Microsoft.PowerShell.Utility/Select-Object.md +++ b/reference/7.1/Microsoft.PowerShell.Utility/Select-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 09/25/2020 +ms.date: 10/15/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Select-Object @@ -147,7 +147,24 @@ b c ``` -### Example 5: Select newest and oldest events in the event log +### Example 5: Using `-Unique` with other parameters + +The **Unique** parameter filters values after other `Select-Object` parameters are applied. For +example, if you use the **First** parameter to select the first number of items in an array, **Unique** +is only applied to the selected values and not the entire array. + +```powershell +"a","a","b","c" | Select-Object -First 2 -Unique +``` + +```Output +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 This example gets the first (newest) and last (oldest) events in the Windows PowerShell event log. @@ -161,7 +178,7 @@ $a = Get-EventLog -LogName "Windows PowerShell" $a | Select-Object -Index 0, ($A.count - 1) ``` -### Example 6: Select all but the first object +### Example 7: 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. @@ -173,7 +190,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 7: Rename files and select several to review +### Example 8: 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. @@ -193,7 +210,7 @@ Get-ChildItem *.txt -ReadOnly | Select-Object -First 5 -Wait ``` -### Example 8: Demonstrate the intricacies of the -ExpandProperty parameter +### Example 9: Demonstrate the intricacies of the -ExpandProperty parameter This example demonstrates the intricacies of the **ExpandProperty** parameter. @@ -251,7 +268,7 @@ ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider pro Name NoteProperty string Name=CustomObject ``` -### Example 9: Create custom properties on objects +### Example 10: 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 does not exist, `Select-Object` creates that property as a @@ -269,7 +286,7 @@ MyCustomProperty New Custom Property ``` -### Example 10: Create calculated properties for each InputObject +### Example 11: 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 @@ -527,6 +544,8 @@ Accept wildcard characters: False Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will 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. diff --git a/reference/7.2/Microsoft.PowerShell.Utility/Select-Object.md b/reference/7.2/Microsoft.PowerShell.Utility/Select-Object.md index 91ddb543cc81..9ec23ed80ea5 100644 --- a/reference/7.2/Microsoft.PowerShell.Utility/Select-Object.md +++ b/reference/7.2/Microsoft.PowerShell.Utility/Select-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 09/25/2020 +ms.date: 10/15/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 title: Select-Object @@ -147,7 +147,24 @@ b c ``` -### Example 5: Select newest and oldest events in the event log +### Example 5: Using `-Unique` with other parameters + +The **Unique** parameter filters values after other `Select-Object` parameters are applied. For +example, if you use the **First** parameter to select the first number of items in an array, **Unique** +is only applied to the selected values and not the entire array. + +```powershell +"a","a","b","c" | Select-Object -First 2 -Unique +``` + +```Output +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 This example gets the first (newest) and last (oldest) events in the Windows PowerShell event log. @@ -161,7 +178,7 @@ $a = Get-EventLog -LogName "Windows PowerShell" $a | Select-Object -Index 0, ($A.count - 1) ``` -### Example 6: Select all but the first object +### Example 7: 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. @@ -173,7 +190,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 7: Rename files and select several to review +### Example 8: 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. @@ -193,7 +210,7 @@ Get-ChildItem *.txt -ReadOnly | Select-Object -First 5 -Wait ``` -### Example 8: Demonstrate the intricacies of the -ExpandProperty parameter +### Example 9: Demonstrate the intricacies of the -ExpandProperty parameter This example demonstrates the intricacies of the **ExpandProperty** parameter. @@ -251,7 +268,7 @@ ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider pro Name NoteProperty string Name=CustomObject ``` -### Example 9: Create custom properties on objects +### Example 10: 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 does not exist, `Select-Object` creates that property as a @@ -269,7 +286,7 @@ MyCustomProperty New Custom Property ``` -### Example 10: Create calculated properties for each InputObject +### Example 11: 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 @@ -527,6 +544,8 @@ Accept wildcard characters: False Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will 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.