Skip to content

Commit

Permalink
Standardize warning about cryptographic security to all versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwheeler committed Dec 11, 2023
1 parent 09b90c7 commit 33f52f2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
15 changes: 8 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/25/2023
ms.date: 12/11/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 @@ -40,14 +40,16 @@ You can use the parameters of `Get-Random` to specify the minimum and maximum va
objects returned from a collection, or a seed number.

> [!CAUTION]
> This seed value is used for the current command and for all subsequent `Get-Random` commands in
> the current session until you use **SetSeed** again or close the session. You can't reset the seed
> to its default value.
> `Get-Random` doesn't ensure cryptographically secure randomness. The seed value is used for the
> current command and for all subsequent `Get-Random` commands in the current session until you use
> **SetSeed** again or close the session. You can't reset the seed to its default value.
>
> Deliberately setting the seed results in non-random, repeatable behavior. It should only be used
> when trying to reproduce behavior, such as when debugging or analyzing a script that includes
> `Get-Random` commands. Be aware that the seed value could be set by other code in the same
> session, such as an imported module.
>
> PowerShell 7.4 includes `Get-SecureRandom`, which ensures cryptographically secure randomness.
## EXAMPLES

Expand Down Expand Up @@ -178,7 +180,7 @@ Get-Random -Maximum 100
```

```powershell
# Commands with the same seed are not random
# Commands with the same seed aren't random
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Expand Down Expand Up @@ -399,7 +401,6 @@ the output type for each of the numeric input types.
| Double | Double |
| Single | Double |

Beginning in Windows PowerShell 3.0, `Get-Random` supports 64-bit integers. In Windows PowerShell
2.0, all values are cast to **System.Int32**.
Beginning in Windows PowerShell 3.0, `Get-Random` supports 64-bit integers.

## RELATED LINKS
12 changes: 7 additions & 5 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/25/2023
ms.date: 12/11/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 @@ -46,14 +46,16 @@ You can use the parameters of `Get-Random` to specify the minimum and maximum va
objects returned from a collection, or a seed number.

> [!CAUTION]
> This seed value is used for the current command and for all subsequent `Get-Random` commands in
> the current session until you use **SetSeed** again or close the session. You can't reset the seed
> to its default value.
> `Get-Random` doesn't ensure cryptographically secure randomness. The seed value is used for the
> current command and for all subsequent `Get-Random` commands in the current session until you use
> **SetSeed** again or close the session. You can't reset the seed to its default value.
>
> Deliberately setting the seed results in non-random, repeatable behavior. It should only be used
> when trying to reproduce behavior, such as when debugging or analyzing a script that includes
> `Get-Random` commands. Be aware that the seed value could be set by other code in the same
> session, such as an imported module.
>
> PowerShell 7.4 includes `Get-SecureRandom`, which ensures cryptographically secure randomness.
## EXAMPLES

Expand Down Expand Up @@ -180,7 +182,7 @@ Get-Random -Maximum 100
```

```powershell
# Commands with the same seed are not random
# Commands with the same seed aren't random
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Expand Down
12 changes: 7 additions & 5 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/25/2023
ms.date: 12/11/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 @@ -46,14 +46,16 @@ You can use the parameters of `Get-Random` to specify the minimum and maximum va
objects returned from a collection, or a seed number.

> [!CAUTION]
> This seed value is used for the current command and for all subsequent `Get-Random` commands in
> the current session until you use **SetSeed** again or close the session. You can't reset the seed
> to its default value.
> `Get-Random` doesn't ensure cryptographically secure randomness. The seed value is used for the
> current command and for all subsequent `Get-Random` commands in the current session until you use
> **SetSeed** again or close the session. You can't reset the seed to its default value.
>
> Deliberately setting the seed results in non-random, repeatable behavior. It should only be used
> when trying to reproduce behavior, such as when debugging or analyzing a script that includes
> `Get-Random` commands. Be aware that the seed value could be set by other code in the same
> session, such as an imported module.
>
> PowerShell 7.4 includes `Get-SecureRandom`, which ensures cryptographically secure randomness.
## EXAMPLES

Expand Down Expand Up @@ -180,7 +182,7 @@ Get-Random -Maximum 100
```

```powershell
# Commands with the same seed are not random
# Commands with the same seed aren't random
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Expand Down
13 changes: 7 additions & 6 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/25/2023
ms.date: 12/11/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 @@ -46,16 +46,17 @@ You can use the parameters of `Get-Random` to specify the minimum and maximum va
objects returned from a collection, or a seed number.

> [!CAUTION]
> This seed value is used for the current command and for all subsequent `Get-Random` commands in
> the current session until you use **SetSeed** again or close the session. You can't reset the seed
> to its default value.
> `Get-Random` doesn't ensure cryptographically secure randomness. The seed value is used for the
> current command and for all subsequent `Get-Random` commands in the current session until you use
> **SetSeed** again or close the session. You can't reset the seed to its default value.
>
> Deliberately setting the seed results in non-random, repeatable behavior. It should only be used
> when trying to reproduce behavior, such as when debugging or analyzing a script that includes
> `Get-Random` commands. Be aware that the seed value could be set by other code in the same
> session, such as an imported module.
>
> `Get-Random` does not ensure cryptographically secure randomness and it is recommended to use [Get-SecureRandom](Get-SecureRandom.md) instead.
> PowerShell 7.4 includes [Get-SecureRandom](Get-SecureRandom.md), which ensures cryptographically
> secure randomness.
## EXAMPLES

Expand Down Expand Up @@ -182,7 +183,7 @@ Get-Random -Maximum 100
```

```powershell
# Commands with the same seed are not random
# Commands with the same seed aren't random
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Get-Random -Maximum 100 -SetSeed 23
Expand Down

0 comments on commit 33f52f2

Please sign in to comment.