Skip Ribbon Commands
Skip to main content

Ondrej Sevecek's English Pages

:

Engineering and troubleshooting by Directory Master!
MCM: Directory

Quick Launch

Ondrej Sevecek's English Pages > Posts > How to archive a certificate with PowerShell
May 16
How to archive a certificate with PowerShell

There is a nice blog post about marking certificates as archived using certutil and vbscript, yet it does not provide a solution for doing so from PowerShell. Here comes my one. The following example flags the second certificate from user personal certificate store with the Archived bit. The only problem was to realize the ReadWrite open flag for the X509Store.Open method - unless that, you receive Access Denied errors:

$personalStore = Get-Item cert:\CurrentUser\My

$personalStore.Open('ReadWrite')

$personalStore.Certificates[1].Archived = $true

 

Comments

Re: How to archive a certificate with PowerShell

how to un-archive some or all archived certificates from the local machine certificate store:

$personalStore = Get-Item cert:\LocalMachine\My
$personalStore.Open('ReadWrite,IncludeArchived')
$personalStore.Certificates | Select Thumbprint, Subject, Archived

$personalStore.Certificates[1].Archived = $false

 on 13/01/2017 10:25

Re: How to archive a certificate with PowerShell

You should then execute

    $personalStore.Close()

before attempting to look at the certificate store through another path of access (like the MMC, for that matter)...
 on 14/11/2018 15:43

Add Comment

Sorry comments are disable due to the constant load of spam *


This simple antispam field seems to work well. Just put here the number.

Title


You do not need to provide any value this column. It will automatically fill with the name of the article itself.

Author *


Body *


Attachments