gpt4 book ai didi

powershell - 从哪里开始为此创建 Powershell 脚本?

转载 作者:行者123 更新时间:2023-12-02 23:16:03 25 4
gpt4 key购买 nike

如果我需要为证书提供如下所述的额外权限,我什至从哪里开始在 Powershell 中?必须有一个 Windows 命令行可执行文件,我必须从命令行开始。只有这样我才能考虑用 powershell 脚本编写它,对吗?

  1. Click Start, type mmc in the Search programs and files box, and then press ENTER.
  2. On the File menu, click Add/Remove Snap-in.
  3. Under Available snap-ins, double-click Certificates.
  4. Select Computer account, and then click Next.
  5. Click Local computer, and then click Finish. Click OK.
  6. Under Console Root, Certificates (Local Computer), in the Personal store, click Certificates.
  7. Right-click xxAzurehost1 certificate that has been created earlier. Choose All Tasks > Manage Private Keys. Click Add and then Advanced. Click Locations and choose your local computer. Click Find Now. Select NETWORK SERVICE in the search results and click OK. Click OK. In the Permissions for xxxazurehost1 private keys window, select NETWORK SERVICE and give Read permissions. Click OK.

最佳答案

要控制私钥的 ACL,您只需编辑文件 ACL。诀窍是找到哪个文件。

私钥存储在:

%ProgramData%\Microsoft\Crypto

在 XP 上:
C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto

在这里,您将看到按算法组织的键,例如DSS,RSA。

用户存储将是具有用户 SID 的子文件夹。本地机器存储将位于子文件夹中:
MachineKeys

这是一种获取存储证书私钥信息的文件的方法。
  • 首先进入本地机器个人证书存储:
    PS> cd cert:\LocalMachine\My
  • 现在你必须处理你的证书。有不止一种方法可以做到这一点,这里有一种使用指纹的方法:
    $cert = dir | ? {$_.Thumbprint -eq "232820EEBF7DBFA01EE68A28BA0450671F862AE1"}
  • 现在您可以像这样找到私钥文件名:
    $fileName = $cert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
    $keyFile = dir -Path "C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto" -Recurse | ? {$_.Name -eq $fileName}
  • $keyFile 将是 FileInfo 对象,您可以使用 Set-ACL 或 icacls.exe
  • 更改 ACL

    关于powershell - 从哪里开始为此创建 Powershell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8376468/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com