PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

Use the newest CA in case of multiple available CAs or old CAs present

Open gitnol opened this issue 6 months ago • 0 comments

https://github.com/J0F3/PowerShell/blob/71ad3619a08a58cf770fe23f7cfe55b309ac0d53/Request-Certificate.ps1#L366

in order to get the newest CA (in case of a CA which is older but alphabetically before the new CA) change this line (366) to:

            if($CAs.Count -ge 1){
                $newestCA = $CAs | Sort-Object -Property {$_.Properties.whenchanged} -Descending | Select -First 1
                $CAName = "$($newestCA.Properties.dnshostname)\$($newestCA.Properties.cn)"
            }
            else {
                $CAName = ""
            }

Further... it is more readable than using the Index 0 of the Array. :)

Thanks for your code. It helps a lot. I will adapt it for me

gitnol avatar Aug 24 '24 15:08 gitnol