Files
PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs
T
Steve LeeandJames Truher [MSFT] a153446a01 Add Get-SecureRandom cmdlet (#19587)
* Add `Get-SecureRandom` cmdlet

* update comments

* address Paul and Travis' comments

* Update test/powershell/Modules/Microsoft.PowerShell.Utility/Get-SecureRandom.Tests.ps1

Co-authored-by: James Truher [MSFT] <jimtru@microsoft.com>

* address codefactor

* address Ilya's feedback creating a base class for both cmdlets

* remove unused `using`

---------

Co-authored-by: James Truher [MSFT] <jimtru@microsoft.com>
2023-05-02 10:54:39 -07:00

37 lines
1.2 KiB
C#

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Management.Automation;
namespace Microsoft.PowerShell.Commands
{
/// <summary>
/// This class implements `Get-Random` cmdlet.
/// </summary>
[Cmdlet(VerbsCommon.Get, "Random", DefaultParameterSetName = GetRandomCommandBase.RandomNumberParameterSet,
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=2097016", RemotingCapability = RemotingCapability.None)]
[OutputType(typeof(int), typeof(long), typeof(double))]
public sealed class GetRandomCommand : GetRandomCommandBase
{
/// <summary>
/// Seed used to reinitialize random numbers generator.
/// </summary>
[Parameter]
[ValidateNotNull]
public int? SetSeed { get; set; }
/// <summary>
/// This method implements the BeginProcessing method for get-random command.
/// </summary>
protected override void BeginProcessing()
{
if (SetSeed.HasValue)
{
Generator = new PolymorphicRandomNumberGenerator(SetSeed.Value);
}
base.BeginProcessing();
}
}
}