首页 > 解决方案 > 使用 certreq 从企业 CA 请求证书时如何抑制弹出窗口?

问题描述

我正在尝试从与我们的企业 CA 服务器位于同一域中的计算机请求证书。一切正常,但我离使我的脚本具有零用户交互仅一步之遥。

我基本上修改了以下脚本以不包含任何参数并删除了 SAN 选项:

https://gallery.technet.microsoft.com/scriptcenter/Request-certificates-from-b6a07151

在使用以下命令从 .inf 文件创建新请求后,我得到一个弹出窗口:

Invoke-Expression -Command "certreq -new `"$inf`" `"$req`""

Machine context template conflicts with user context.

当我单击确定时,一切正常。创建了一个新请求,脚本的其余部分工作正常。但是我找不到以编程方式单击“确定”的方法。

certreq 工具确实具有-q(抑制交互式提示)和-f(强制/绕过事物),但这些都不起作用。

certreq -new -q $inf $req或同时使用-q-f导致:

Active Directory Enrollment Policy
  {<GUID>}
  ldap:
Machine context template conflicts with user context.
Certificate Request Processor: The specified role was not configured for the application 0x8004e00c (-2147164148 CONTEXT_E_ROLENOTFOUND)

我几乎被困在这里。任何帮助,将不胜感激!

标签: powershellcertificatepopupwindowcacertreq

解决方案


您的问题的答案应该是更改 Request-Certificate.ps1 中的参数。查看用于生成请求的 inf 文件并检查MachineKeySet参数。默认为 false 并提示:

Machine context template conflicts with user context.

当模板是一种机器时出现。当您将其切换为真正的 ale 使用用户模板时,会出现相反的提示:

User context template conflicts with machine context.

推荐阅读