Functions/SSL/Get-CertStoreInfo.ps1
Function Get-CertStoreInfo { [cmdletbinding()] Param ( # Location (Current User or LocalMachine) [Parameter(Mandatory=$False)] [ValidateSet("LocalMachine","CurrentUser")] [String] $Location = "LocalMachine", [Parameter(Mandatory=$False)] [Switch] $Reverse = $false ) Process { $LocationMap = Switch ($Location) { "LocalMachine" {""} "CurrentUser" {"-user"} } $RawEnum = certutil -enumstore $LocationMap $TrimEnum = $RawEnum[10..($RawEnum.count-2)] $CleanEnum = foreach ($line in $TrimEnum) { $NewLine = if($line -like "*`"*"){($Line).trimstart() -replace '\s{2,}','='} else {$Line+"="} $newline -replace '"','' } $Hash = $CleanEnum | ConvertFrom-StringData $FinalEnum = switch ($Reverse) { $false { $NewHash = [ordered]@{} Foreach ($Val in ($Hash.Values -notlike "")){$NewHash.Add($Val,($Hash.keys | where {$Hash.$_ -eq $Val}))} [pscustomobject]($NewHash) } $true {[pscustomobject]($Hash)} } $FinalEnum } } |