2017-08-10 1 views
2

J'essaie d'utiliser New-SelfSignedCertificate dans PowerShell pour créer un certificat sur Windows 10, mais la commande me donne une erreur d'autorisations. J'utilise un compte administrateur.New-SelfSignedCertificate pour créer le certificat donne accès refusé

Commande:

New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName MyCert -CertStoreLocation "Cert:\LocalMachine\My" 

Sortie:

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 
+1

Pouvez-vous accéder « Cert: \ LocalMachine \ Mon » emplacement, i.e.. voir la sortie de '' 'Get-item" Cert: \ LocalMachine \ My "' '' – Curios

+0

Cela ressemble à ça. Pas d'erreur mais la sortie est juste 'Name: My' – wildabeast

+0

Est-ce que' New-SelfSignedCertificate' quelque chose que vous avez écrit vous-même? – TheIncorrigible1

Répondre

1

Comme mentionné dans les commentaires, bien que PowerShell.exe est exécuté sous un compte utilisateur avec "droits administratifs". Le processus ne peut pas utiliser ces droits sauf s'il est élevé.

Windows PowerShell ajoutera "Administrateur:" dans la barre de titre par défaut. Sinon, vous pouvez vérifier si vous un administrateur en exécutant cette commande:

([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole‌​([Security.Principal‌​.WindowsBuiltInRole] "Administrator") 

Lorsque vous lancez PowerShell si elle est faite par l'interface graphique, vous pouvez clic droit -> Exécuter en tant qu'administrateur.

Sinon, vous pouvez lancer un nouveau processus qui est élevé en exécutant Start-Process powershell.exe -Verb Runas