Author Posts

September 27, 2017 at 2:24 pm

How kan I find a certificate in server with Powershell script?

September 28, 2017 at 12:31 am

Certificates can be found in the cert drive.

Get-ChildItem Cert:\ -Recurse

September 28, 2017 at 6:39 am

I want the command to return a certificate name. (Issued to)

September 28, 2017 at 9:26 am

cosmic,

You can only get back what is available.

if you take a look at the all the available properties, a property name titled 'IssueTo' is not an option.
The UI in Windows Sever is using another method to display that portion.

(gci Cert:\LocalMachine\My | Select -Property *) | Get-Member | Select Name

Even getting at the hidden properties, does not show an IssuedTo property

(gci Cert:\LocalMachine\My | Select -Property *) | Get-Member -Force | Select Name

Yet, as a point of note: by default, the string shown in the 'Issued To' message in the ADCS cert UI is the 'Subject' name of the cert

However, I also want to point out, if you really need this or just want to do this you need to go about it another way. Meaning calculate it yourself.

For example:
The below is using a call to the X509 methods directly. See the details here:
'msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.getnameinfo.aspx'

Get-ChildItem cert:\LocalMachine\My |
Format-Table Subject, @{ Label = 'IssuedTo'; Expression = { $_.GetNameInfo( 'SimpleName', $false ) } },
@{ Label = 'IssuedBy' ;Expression = { $_.GetNameInfo( 'SimpleName', $true ) } }

September 28, 2017 at 10:26 am

There is a certificate called Novaboard! How can I look for this certificate on a server?

September 28, 2017 at 8:59 pm

Try this:

get-childitem cert: -recurse | ? {$_.FriendlyName -match "Novaboard"} | fl *

September 28, 2017 at 10:23 pm

If PowerShell Remoteing (WSMan and or DCOM)...

'technet.microsoft.com/en-us/library/ff700227.aspx'
'docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enable-psremoting?view=powershell-5.1'
'technet.microsoft.com/en-us/library/gg981683.aspx'

... you can just use the Invoke-Command cmdlet to point to that computer and run whatever code you wish...

Example:
Invoke-Command -ComputerName 'put you computer name here' -ScriptBlock { (Get-ChildItem -Path Cert:\LocalMachine -Recurse) -match 'your certificate name / subject'}

... well as long as you have admin rights on the server and you need admin rights for PowerShell Remoteing to function.

October 3, 2017 at 12:40 pm

Hi,
i try to get expired cert, but i get different result and its not what i need

Invoke-Command -ComputerName Comp123 -ScriptBlock {
    Get-ChildItem Cert:\ -Recurse | Format-Table Subject, @{ Label = 'IssuedTo'; Expression = { $_.GetNameInfo( 'SimpleName', $false ) } },
@{ Label = 'IssuedBy' ;Expression = { $_.GetNameInfo( 'SimpleName', $true ) }
}}

and

$comp = Get-ChildItem cert:\LocalMachine\My |
Format-Table Subject, @{ Label = 'IssuedTo'; Expression = { $_.GetNameInfo( 'SimpleName', $false ) } },
@{ Label = 'IssuedBy' ;Expression = { $_.GetNameInfo( 'SimpleName', $true )}}

$comp

Please, help
Thanks