Skip to content

Commit

Permalink
Clarify how -Count works (#10207)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwheeler committed Jun 26, 2023
1 parent eb4b283 commit fa013b6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 29 deletions.
14 changes: 7 additions & 7 deletions reference/5.1/Microsoft.PowerShell.Utility/Get-Random.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/12/2023
ms.date: 06/25/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-random?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-Random
Expand Down Expand Up @@ -241,10 +241,13 @@ Name Count

### -Count

Specifies the number of random objects or numbers to return. The default is 1.
Specifies the number of random objects to return. The default is 1.

When used with `InputObject`, if the value of **Count** exceeds the number of objects in the
collection, `Get-Random` returns all the objects in random order.
When used with `InputObject` containing a collection:

- Each randomly selected item is returned only once.
- If the value of **Count** exceeds the number of objects in the collection, all objects in the
collection are returned in random order.

```yaml
Type: System.Int32
Expand Down Expand Up @@ -380,9 +383,6 @@ submitted collection.
## NOTES
By default, `Get-Random` generates cryptographically secure randomness using the
[RandomNumberGenerator](/dotnet/api/system.security.cryptography.randomnumbergenerator) class.

`Get-Random` doesn't always return the same data type as the input value. The following table shows
the output type for each of the numeric input types.

Expand Down
14 changes: 7 additions & 7 deletions reference/7.2/Microsoft.PowerShell.Utility/Get-Random.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/12/2023
ms.date: 06/25/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-random?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-Random
Expand Down Expand Up @@ -270,10 +270,13 @@ and `$null` returns to a PowerShell prompt.

### -Count

Specifies the number of random objects or numbers to return. The default is 1.
Specifies the number of random objects to return. The default is 1.

When used with `InputObject`, if the value of **Count** exceeds the number of objects in the
collection, `Get-Random` returns all the objects in random order.
When used with `InputObject` containing a collection:

- Each randomly selected item is returned only once.
- If the value of **Count** exceeds the number of objects in the collection, all objects in the
collection are returned in random order.

```yaml
Type: System.Int32
Expand Down Expand Up @@ -428,9 +431,6 @@ submitted collection.
## NOTES
By default, `Get-Random` generates cryptographically secure randomness using the
[RandomNumberGenerator](/dotnet/api/system.security.cryptography.randomnumbergenerator) class.

`Get-Random` doesn't always return the same data type as the input value. The following table shows
the output type for each of the numeric input types.

Expand Down
14 changes: 7 additions & 7 deletions reference/7.3/Microsoft.PowerShell.Utility/Get-Random.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/12/2023
ms.date: 06/25/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-random?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-Random
Expand Down Expand Up @@ -270,10 +270,13 @@ and `$null` returns to a PowerShell prompt.

### -Count

Specifies the number of random objects or numbers to return. The default is 1.
Specifies the number of random objects to return. The default is 1.

When used with `InputObject`, if the value of **Count** exceeds the number of objects in the
collection, `Get-Random` returns all the objects in random order.
When used with `InputObject` containing a collection:

- Each randomly selected item is returned only once.
- If the value of **Count** exceeds the number of objects in the collection, all objects in the
collection are returned in random order.

```yaml
Type: System.Int32
Expand Down Expand Up @@ -428,9 +431,6 @@ submitted collection.
## NOTES
By default, `Get-Random` generates cryptographically secure randomness using the
[RandomNumberGenerator](/dotnet/api/system.security.cryptography.randomnumbergenerator) class.

`Get-Random` doesn't always return the same data type as the input value. The following table shows
the output type for each of the numeric input types.

Expand Down
11 changes: 7 additions & 4 deletions reference/7.4/Microsoft.PowerShell.Utility/Get-Random.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/12/2023
ms.date: 06/25/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-random?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-Random
Expand Down Expand Up @@ -272,10 +272,13 @@ and `$null` returns to a PowerShell prompt.

### -Count

Specifies the number of random objects or numbers to return. The default is 1.
Specifies the number of random objects to return. The default is 1.

When used with `InputObject`, if the value of **Count** exceeds the number of objects in the
collection, `Get-Random` returns all the objects in random order.
When used with `InputObject` containing a collection:

- Each randomly selected item is returned only once.
- If the value of **Count** exceeds the number of objects in the collection, all objects in the
collection are returned in random order.

```yaml
Type: System.Int32
Expand Down
11 changes: 7 additions & 4 deletions reference/7.4/Microsoft.PowerShell.Utility/Get-SecureRandom.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: 05/03/2023
ms.date: 06/25/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-securerandom?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-SecureRandom
Expand Down Expand Up @@ -212,10 +212,13 @@ line and `$null` returns to a PowerShell prompt.

### -Count

Specifies the number of random objects or numbers to return. The default is 1.
Specifies the number of random objects to return. The default is 1.

When used with `InputObject`, if the value of **Count** exceeds the number of objects in the
collection, `Get-SecureRandom` returns all the objects in random order.
When used with `InputObject` containing a collection:

- Each randomly selected item is returned only once.
- If the value of **Count** exceeds the number of objects in the collection, all objects in the
collection are returned in random order.

```yaml
Type: System.Int32
Expand Down

0 comments on commit fa013b6

Please sign in to comment.