From 164bb860af919847aed247a7016eb16c109e75bf Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Sun, 4 Sep 2022 10:44:06 -0400 Subject: [PATCH] updated parameters and better question asking for rsa/ecc --- csr.ps1 | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/csr.ps1 b/csr.ps1 index aacf046..dcf81d1 100644 --- a/csr.ps1 +++ b/csr.ps1 @@ -1,13 +1,33 @@ param( - $rsa, + [switch]$rsa, + [switch]$ecc, $hostnames ) -if (-not $PSBoundParameters.ContainsKey('rsa')) { - $test = read-host "Do you want a RSA (r) or EEC (e) cert? (e/r)" +function Get-RSAorECC { + [cmdletbinding()] + param( + [Parameter(Mandatory)] + [string]$title, + [Parameter(Mandatory)] + [string]$question + ) - if ($test -eq "r") { - $rsa = $True + # list of choices for the user + $choices = '&RSA', '&ECC' + # prompt the user to confirm + $decision = $Host.UI.PromptForChoice($title, $question, $choices, 1) + # return value if 0, user entered r for RSA + if ($decision -eq 0) { + return "RSA" + } else { + return "ECC" + } +} + +if (-not $rsa -and -not $ecc) { + if ($(Get-RSAorECC) -eq "RSA") { + $rsa = $true } }