创建证书的 New-SelfSignedCertificate 给出拒绝访问
New-SelfSignedCertificate to create certificate gives Access Denied
我正尝试在 PowerShell 中使用 New-SelfSignedCertificate
在 Windows 10 上创建证书,但该命令给我一个权限错误。我正在使用管理员帐户。
命令:
New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName MyCert -CertStoreLocation "Cert:\LocalMachine\My"
输出:
New-SelfSignedCertificate : CertEnroll::CX509Enrollment::_CreateRequest: Access denied. 0x80090010 (-2146893808 NTE_PERM)
At line:1 char:1
+ New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, ..."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-SelfSignedCertificate], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.CertificateServices.Commands.NewSelfSignedCertificateCommand
如评论中所述,虽然 PowerShell.exe 在 "Administrative Rights" 的用户帐户下是 运行。该进程不能使用这些权限,除非它被提升。
PowerShell windows 默认情况下会在标题栏中添加 "Administrator:"。否则,您可以通过 运行ning 这个命令检查您是否是管理员:
([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
当您通过 GUI 启动 PowerShell 时,您可以 Right-Click -> 运行 作为管理员。
否则,您可以生成一个新进程,该进程由 运行ning Start-Process powershell.exe -Verb Runas
提升
通过指定不同的证书位置为您的本地用户帐户创建证书:
New-SelfSignedCertificate -CertStoreLocation "Cert:\CurrentUser\My" [...]
不是正确答案。 Run-as 权限是问题所在。
我正尝试在 PowerShell 中使用 New-SelfSignedCertificate
在 Windows 10 上创建证书,但该命令给我一个权限错误。我正在使用管理员帐户。
命令:
New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName MyCert -CertStoreLocation "Cert:\LocalMachine\My"
输出:
New-SelfSignedCertificate : CertEnroll::CX509Enrollment::_CreateRequest: Access denied. 0x80090010 (-2146893808 NTE_PERM)
At line:1 char:1
+ New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, ..."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-SelfSignedCertificate], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.CertificateServices.Commands.NewSelfSignedCertificateCommand
如评论中所述,虽然 PowerShell.exe 在 "Administrative Rights" 的用户帐户下是 运行。该进程不能使用这些权限,除非它被提升。
PowerShell windows 默认情况下会在标题栏中添加 "Administrator:"。否则,您可以通过 运行ning 这个命令检查您是否是管理员:
([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
当您通过 GUI 启动 PowerShell 时,您可以 Right-Click -> 运行 作为管理员。
否则,您可以生成一个新进程,该进程由 运行ning Start-Process powershell.exe -Verb Runas
通过指定不同的证书位置为您的本地用户帐户创建证书:
New-SelfSignedCertificate -CertStoreLocation "Cert:\CurrentUser\My" [...]
不是正确答案。 Run-as 权限是问题所在。