我们有一个证书服务器,用户可以从这个URL下载证书(用户模板): http:// localhost / certsrv 。
我现在要创build一个脚本,将执行以下操作:
我已经创build了脚本,并且能够删除证书,但是由于该命令在Windows 7中不支持,安装不会发生。
这是我的代码:
# User Details $dom = $env:userdomain $usr = $env:username $fulname = ([adsi]"WinNT://$dom/$usr,user").fullname #get certificate & Remove the certificate $Cert = Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.Subject -match "$fulname"} | Remove-Item #Install new certificate Get-Certificate -Template User -DnsName mydomain.com -CertStoreLocation cert:\CurrentUser\My
我相信你将需要在Windows 7上使用命令行工具certutil.exe
。它的使用logging在这里: https : //technet.microsoft.com/en-us/library/cc732443(v=ws.11)。 aspx,并在证书服务安装时可用。
例如:
certutil -addstore -user -f "My" "Path to certificate\certificate.cer"
您可以在PowerShell脚本中使用此工具。