使用Powershell创建/复制证书模板

使用Powershell创建/复制证书模板,powershell,certificate,powershell-2.0,Powershell,Certificate,Powershell 2.0,我想使用powershell创建模板,但我似乎无法确定如何为模板设置支持的最小CA。我从来都不知道如何复制一个模板,只是创建一个新的模板 我的代码如下 $temp = ([ADSI]"LDAP://RootDSE".ConfigurationNamingContext $ADSI = [ADSI]"LDAP://CN=Certificate Templates,CN=Public Key Services, CN=Services,$config" $temp = $ADSI.Create("

我想使用powershell创建模板,但我似乎无法确定如何为模板设置
支持的最小CA
。我从来都不知道如何复制一个模板,只是创建一个新的模板

我的代码如下

$temp = ([ADSI]"LDAP://RootDSE".ConfigurationNamingContext
$ADSI = [ADSI]"LDAP://CN=Certificate Templates,CN=Public Key Services, CN=Services,$config"

$temp = $ADSI.Create("pKICertificateTemplate","CN=Web Server 2008-2")
$temp.put("distinguishedName","CN=Web Server 2008-2,CM=Certificate Template,CN=Public Key Services,CN=Services.$Config)

$temp.SetInfo()

这可以创建一个实际的模板,但我希望使用
Windows Server 2008 Enterprise
创建该模板,因为在ADCS中
支持的CAs

,版本1证书是Win200,版本2是2003,版本3是2008

我没有要验证的实验室,但我认为您需要将模板架构设置为3:

$temp.put("msPKI-Template-Schema-Version","3")
$temp.put("msPKI-Template-Minor-Revision","0")  # Not sure if you actually need this.

在ADC中,版本1的证书是Win200,版本2是2003,版本3是2008

我没有要验证的实验室,但我认为您需要将模板架构设置为3:

$temp.put("msPKI-Template-Schema-Version","3")
$temp.put("msPKI-Template-Minor-Revision","0")  # Not sure if you actually need this.

这似乎有效,但模板从未真正显示出来。如果我连续运行它,我会收到一条错误消息,
对象已经存在
,这告诉我它实际上正在工作……但是找不到模板。如前所述,我无能为力。阅读我的资料来源。使用它并注意到schema version属性。顺便说一句,您的示例有一个错误,您为新对象设置了DN。它应该是
…CN=证书模板,…。
而不是
…CM=证书模板,…。
:-)这似乎是可行的,但模板从未实际显示。如果我连续运行它,我会收到一条错误消息,
对象已经存在
,这告诉我它实际上正在工作……但是找不到模板。如前所述,我无能为力。阅读我的资料来源。使用它并注意到schema version属性。顺便说一句,您的示例有一个错误,您为新对象设置了DN。它应该是
…CN=证书模板,.
而不是
…CM=证书模板,.
:-)