Search code examples
windowspowershellcmdcertificate

Execute powershell string via CMD


I try to execute the following command in console:

powershell.exe -NoLogo -Command `"Get-ChildItem "Cert:\CurrentUser\My" | WHERE{$_.Extensions['Certificate Template Name'] -match 'CA'}`"

But I get this error:
error pic here

I need to execute this command in CMD, not ps1 script.


Solution

  • There was in issue with your double quotes.

    I've changed it slightly:

    powershell.exe -NoLogo -Command "Get-ChildItem Cert:\CurrentUser\My | where {$_.Extensions['Certificate Template Name'] -match 'CA'}"