Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 在其他用户上安装证书';s当前用户存储_Powershell_X509certificate_Powershell 4.0 - Fatal编程技术网

Powershell 在其他用户上安装证书';s当前用户存储

Powershell 在其他用户上安装证书';s当前用户存储,powershell,x509certificate,powershell-4.0,Powershell,X509certificate,Powershell 4.0,我当前正在使用以下代码将证书从本地计算机存储添加到当前用户存储,其中$cert是证书 $DestStoreScope = 'CurrentUser' $DestStoreName = 'My' $DestStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $DestStoreName, $DestStoreScope $DestStore.Ope

我当前正在使用以下代码将证书从本地计算机存储添加到当前用户存储,其中$cert是证书

$DestStoreScope = 'CurrentUser'
$DestStoreName = 'My'

$DestStore = New-Object  -TypeName System.Security.Cryptography.X509Certificates.X509Store  -ArgumentList $DestStoreName, $DestStoreScope
$DestStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
$DestStore.Add($cert)


$SourceStore.Close()
$DestStore.Close()

是否有一种方法可以将此证书添加到此计算机上的其他用户当前存储。它将在管理员帐户下运行。任何帮助都将不胜感激。如果你还需要什么,请告诉我

CurrentUser
/
HKEY\U CURRENT\U USER
是注册表中的一个抽象。实际用户数据存储在键
HKEY\U USERS\
中。由于
CurrentUser
总是指当前登录的用户,并且API不允许通过用户的SID访问证书存储,因此您的唯一选项(AFAICS)是在您希望安装证书的用户的上下文中运行脚本。

HKEY\U USERS\
只是
%USERPROFILE%\NTUSER.DAT的表示形式。如果在RegEdit中选择了
HKEY_用户
,则可以转到
文件->加载配置单元
,并通过导航到该文件来加载已卸载的用户注册表。