Functions/SSL/Get-CertCSPs.ps1
Function Get-CertCSPs { [cmdletbinding()] Param ( # SmartCard CSP Switch [Parameter(Mandatory=$false)] [switch] $IncludeSmartCard = $false ) Process { $CSPRaw = Certutil -csplist $CSPRaw2 = Foreach ($line in $CSPRaw) { if ($Line -like ""){$line = '&'} $Line } $CSPArray = $CSPRaw2 -join '@' -split '&' $Output = foreach ($CSP in $CSPArray) { $CSPData = ($CSP -split '@').trim() $CSPHash = $CSPData -notlike "CertUtil*" -replace ':','=' | ConvertFrom-StringData $Type = if($CSPHash.'Provider Type'){"Legacy"}else{"CNG"} [pscustomobject]([ordered]@{ Name = $CSPHash.'Provider Name' Type = $Type TypeName = $CSPHash.'Provider Type' }) } $SmartcardCSPs = "Microsoft Smart Card Key Storage Provider","Microsoft Base Smart Card Crypto Provider" if(!$IncludeSmartCard){$Output | where name -notin $SmartcardCSPs}else{$Output} } } |