PowerShell导出AD用户x509证书并为用户导入ADUC

PowerShell导出AD用户x509证书并为用户导入ADUC,powershell,import,export,x509certificate2,Powershell,Import,Export,X509certificate2,PowerShell中导出用户AD证书并存储在数据文件中的最佳方法是什么 我可以获得用户证书: $user = Get-ADuser "tester01" $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $user.usercertificate 我想将其导出到一个文件,以便以后可以使用PowerShell将其导入到用户广告帐户 如何做到这一点?PKI颁发的用

PowerShell中导出用户AD证书并存储在数据文件中的最佳方法是什么

我可以获得用户证书:

$user = Get-ADuser "tester01"
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $user.usercertificate
我想将其导出到一个文件,以便以后可以使用PowerShell将其导入到用户广告帐户


如何做到这一点?

PKI颁发的用户证书位于他们的计算机上。只需使用证书驱动器即可获取它们。获取PSDrive,获取ChildItem-路径证书:。请参阅帮助文件和帮助文件示例

或者使用

模块:PKI客户端

将证书从证书存储导出到文件中

#获取模块、cmdlet或函数的详细信息
(Get命令-名称导出证书)。参数
(获取命令-名称导出证书)。Parameters.Keys
获取帮助-名称导出证书-示例
#结果
获取帮助-名称导出证书-完整
获取帮助-名称导出证书-联机
另见:


你能告诉我们你为什么需要这个吗?我需要这个用于证书管理和恢复自动化。今晚我会测试它,让你知道它是否适用于我的应用程序。
# Get specifics for a module, cmdlet, or function
(Get-Command -Name Export-Certificate).Parameters
(Get-Command -Name Export-Certificate).Parameters.Keys
Get-help -Name Export-Certificate -Examples
# Results
<#
$cert = (Get-ChildItem -Path 
Export-Certificate -Cert $cert -FilePath c:\certs\user.sst -Type SST
$cert = (Get-ChildItem -Path 
Export-Certificate -Cert $cert -FilePath c:\certs\user.cer
$cert = ( Get-ChildItem -Path 
Export-Certificate -Cert $cert -FilePath c:\certs\user.p7b -Type p7b
Get-ChildItem -Path cert:\CurrentUser\my | Export-Certificate ûFilePath 

#>
Get-help -Name Export-Certificate -Full
Get-help -Name Export-Certificate -Online