Share via


PKI; combine -Filter values for Get-IssuedRequest cmdlet

Question

Thursday, September 21, 2017 2:35 PM

Does anyone know of a way to combine values for the -Filter operator in Get-IssuedRequest? 

...Something like the following;

Get-CertificationAuthority -name CAinstance | Get-IssuedRequest -Filter "CertificateTemplate -eq WebServer" -or "Basic EFS" 

All of my various attempts to combine values for this operator (eg comma, single quotes, etc) make me suspect it's not possible. 

All replies (10)

Thursday, September 21, 2017 5:45 PM ✅Answered

Get-CertificationAuthority -name CAinstance | 
    Get-IssuedRequest | 
    Where{$_.CertificateTemplate -eq 'WebServer' -Or $_.CertificateTemplate -eq 'Basic EFS'}

\(ツ)_/


Thursday, September 21, 2017 6:27 PM ✅Answered

ha! that's much more elegant and worked nicely  - thanks, jrv!

I only needed to expand the 'CertificateTemplate' property for it to return results; 

Get-CertificationAuthority -name CAinstance | 
    Get-IssuedRequest -Property CertificateTemplate | 
    Where{$_.CertificateTemplate -eq 'WebServer' -Or $_.CertificateTemplate -eq 'Basic EFS'}

Thursday, September 21, 2017 2:51 PM

Filter syntax!

IssuedRequest -Filter "CertificateTemplate -eq 'WebServer'"

Strings require quotes. 

\(ツ)_/


Thursday, September 21, 2017 2:59 PM

Thanks, jrv. 

In your example, those single quotes that are nested in your double quotes fail on my end - the double quotes alone work fine. Nonetheless, taking this one step further, is it possible to combine two values on this same property (CertificateTemplate)? 


Thursday, September 21, 2017 3:03 PM

I think you should start here: https://www.sysadmins.lv/projects/pspki/get-issuedrequest.aspx

Read all of it and pay attention to the examples.

\(ツ)_/


Thursday, September 21, 2017 3:08 PM

Unfortunately the filter syntax is not like that for PKI module which is why I linked the post.

\(ツ)_/


Thursday, September 21, 2017 3:13 PM

Thanks, Richard- but I'm afraid that jrv is correct here- the message I get back is with that syntax is;

"WARNING: Specified column 'CertificateTemplate -eq 'WebServer' -Or CertificateTemplate' does not exist!"

Also, I've read the post linked before posting here and it didn't address what I'm trying to achieve so I'm thinking this isn't possible and I'll just move to plan 'B' on this.

Thanks!


Thursday, September 21, 2017 3:25 PM

It appears that the example in the link combines differing property's (and their values) with the -Filter operator however I'm not seeing one where two values for the same property (eg CertificateTemplate) are displayed. 

I figure I can simply assign each scenario to a variable and combine those two into a single variable. Like,

$Case1 = Get-CertificationAuthority -name CAinstance | Get-IssuedRequest -Filter "CertificateTemplate -eq WebServer"
$Case2 = Get-CertificationAuthority -name CAinstance | Get-IssuedRequest -Filter "CertificateTemplate -eq "Basic EFS" 

$Goal = $Case1 + $Case2


Thursday, September 21, 2017 3:31 PM

Go back and read example 1 and example 4 very carefully.  They shows exactly how to do this.

\(ツ)_/


Thursday, September 21, 2017 5:23 PM

Thanks, guys - I do see where the examples use a combination of property's for the '-Filter' switch however the comma that separates each one is acting like an 'and' operator and not an 'or' operator - which is what I was seeking. No worries - I'll get this cat skinned!