Powershell管理证书,申请、导入.note

noteId: 957F9D7EE45246E0AC82687ADE9E77E0 · 原始路径:/ALL/Windows - B模块/服务配置/CA证书 AD CS证书服务/Powershell管理证书,申请、导入.note · 图片:5 · 附件待处理:0

 
powershell 中的 ls 等同于 Get-ChildItem(ls等同于是它的别名)
 
ls Cert:\LocalMachine\My\
ls Cert:\CurrenUser\
ls Cert:\LocalMachine\REQUEST\ | Get-Certificate    //获取已颁发证书
[允许使用Tab键]
 
Cert == 证书前缀
LocalMachine == 本地计算机
CurrenUser == 当前用户
My == 个人
REQUEST == 证书注册申请
获取成功
 
 提供一个凭证,以进行连接CA
 ls Cert:\LocalMachine\REQUEST\ | Get-Certificate -Credential $(Get-Credential)
 
ls c:\
 
 
ls
 
 
一、导入证书:
 
1、导入 .cer 证书:
Import-Certificate -FilePath "C:\path\to\your\certificate.cer" -CertStoreLocation "Cert:\LocalMachine\My"
 
或:
Import-Certificate -FilePath "C:\path\to\your\certificate.cer" -CertStoreLocation "Cert:\CurrentUser\My"
 
 
 
2、导入 .pfx 证书:
cmd:
certutil -importpfx c:\share\ca.pfx
# 然后会提示需要输入证书的密码
 
 
powershell:
Import-PfxCertificate -FilePath C:\share\ca.pfx -CertStoreLocation cert:\localmachine\my -Password (ConvertTo-SecureString -String 1 -AsPlainText -Force)