<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to export issued certificates from a CA programatically (PowerShell)</title><link>http://blogs.msdn.com/b/alejacma/archive/2012/04/13/how-to-export-issued-certificates-from-a-ca-programatically-powershell.aspx</link><description>Hi all, 
 
 The following sample is a conversion of How to export issued certificates from a CA programatically (C#) sample to PowerShell . It will get all the issued certs in the CA database and copy them to a folder: 
 
 #Params $strServer = "myserver</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How to export issued certificates from a CA programatically (PowerShell)</title><link>http://blogs.msdn.com/b/alejacma/archive/2012/04/13/how-to-export-issued-certificates-from-a-ca-programatically-powershell.aspx#10320504</link><pubDate>Fri, 15 Jun 2012 14:15:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10320504</guid><dc:creator>Stefan Horz</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;for me this is very interesting.&lt;/p&gt;
&lt;p&gt;Is this possible to get with this code one certificate thats meet a criteria (e.g. Disply name = Firstname Lastname).&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Stefan Horz&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10320504" width="1" height="1"&gt;</description></item><item><title>re: How to export issued certificates from a CA programatically (PowerShell)</title><link>http://blogs.msdn.com/b/alejacma/archive/2012/04/13/how-to-export-issued-certificates-from-a-ca-programatically-powershell.aspx#10293785</link><pubDate>Sat, 14 Apr 2012 15:53:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10293785</guid><dc:creator>Vadims Podans</dc:creator><description>&lt;p&gt;The code is not very efficient. At first, you don&amp;#39;t need to add all columns to the view. For the current task it is enough to add RequestID and rawCertificate columns. The part:&lt;/p&gt;
&lt;p&gt; # Place each column in the view&lt;/p&gt;
&lt;p&gt;for ($x=0; $x -lt $iColumnCount; $x++) { $objCertView.SetResultColumn($x) } &lt;/p&gt;
&lt;p&gt;should be replaced with:&lt;/p&gt;
&lt;p&gt;$objCertView.SetResultColumnCount(2)&lt;/p&gt;
&lt;p&gt;$Column = $objCertView.GetColumnIndex($false,&amp;quot;RequestID&amp;quot;)&lt;/p&gt;
&lt;p&gt;$objCertView.SetResultColumn($Column)&lt;/p&gt;
&lt;p&gt;$Column = $objCertView.GetColumnIndex($false,&amp;quot;RawCertificate&amp;quot;)&lt;/p&gt;
&lt;p&gt;$objCertView.SetResultColumn($Column)&lt;/p&gt;
&lt;p&gt;the next: the code dumps entire Request table (which includes issued, revoked, pending and denied requests). It is reasonable to limit DB search to required request state — Issued certificates. In that case you need to set restriction based on disposition ID (which is 20 for issued certificates). Add the code to previous modification:&lt;/p&gt;
&lt;p&gt;$RColumn = $objCertView.GetColumnIndex($False, &amp;quot;Disposition&amp;quot;)&lt;/p&gt;
&lt;p&gt;$objCertView.SetRestriction($RColumn,1,0,20)&lt;/p&gt;
&lt;p&gt;and then open view.&lt;/p&gt;
&lt;p&gt;p.s. $objCertViewRow.Reset(); — for what reason you reset enumerator when it is already set to initial position?&lt;/p&gt;
&lt;p&gt;p.p.s. Set-Content $strPath $objValue — by default Set-Content cmdlet saves the file by using Unicode encoding which may be not supported by 3rd party tools (hence, Windows Server 2008 R2 CA still do not support Unicode requests!) and waste disk space. You should use ASCII encoding for saved files:&lt;/p&gt;
&lt;p&gt;Set-Content -Path $strPath -Value $objValue -Encoding ASCII&lt;/p&gt;
&lt;p&gt;p.p.p.s in PowerShell it is not necessary to place BREAK statement after each case element. This is because PowerShell supports multiple case matching.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10293785" width="1" height="1"&gt;</description></item></channel></rss>