Powershell 添加保护状态注册表项的脚本

Powershell 添加保护状态注册表项的脚本,powershell,Powershell,我需要使用以下PS命令在PowerShell中创建脚本,并在计算机\HKEY\u本地\u机器\SOFTWARE\Policies\Microsoft\FVE中创建注册表项,结果为“保护状态:保护关闭或打开” 请参见下面的输出示例: BitLocker Drive Encryption: Configuration Tool version 6.1.7601 Copyright (C) Microsoft Corporation. All rights reserved. Computer Na

我需要使用以下PS命令在PowerShell中创建脚本,并在
计算机\HKEY\u本地\u机器\SOFTWARE\Policies\Microsoft\FVE
中创建注册表项,结果为“保护状态:保护关闭或打开”

请参见下面的输出示例:

BitLocker Drive Encryption: Configuration Tool version 6.1.7601
Copyright (C) Microsoft Corporation. All rights reserved.

Computer Name: localhost

Disk volumes that can be protected with
BitLocker Drive Encryption:
Volume C: [OSD]
[OS Volume]

    Size:                 232.59 GB
    BitLocker Version:    Windows 7
    Conversion Status:    Encryption in Progress
    Percentage Encrypted: 45%
    Encryption Method:    AES 128 with Diffuser
    Protection Status:    Protection Off
    Lock Status:          Unlocked
    Identification Field: None
    Key Protectors:
        TPM

要确定保护是打开还是关闭,请执行以下操作:

[string]$ProtectionStatus

if(@((manage-bde -status -cn localhost) -like '*Protection On').Count -gt 0){
    $ProtectionStatus = "Protection On"
}

else {$ProtectionStatus = "Protection Off"}
我不确定您到底想做什么——我假设FVE是一个注册表项(在注册表编辑器中显示为文件夹)。要添加一个新的字符串值“MyTestEntry”,并将数据放入上面的$ProtectionStatus变量中,请执行以下操作:

New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\FVE -Name MyTestEntry -PropertyType String -Value "$ProtectionStatus"


如果这对你没有帮助,请仔细解释你想要什么。如果您只需要该命令来创建字符串注册表项,那么manage-bde命令的输出是不相关的。如果您希望以某种方式使用该命令的输出,以便在创建注册表项的命令中使用,然后,您需要非常清楚要解析的内容以及它在注册表中之后的确切外观。

如果您能够证明您已经对此进行了研究,并展示了一些您尝试过的代码,您可能会得到更好的结果。要求在没有显示任何努力的情况下编写代码的请求通常会被忽略。到目前为止,我仅有的一个请求是:Set Item-Path HKLM:\Software\Policies\Microsoft\FVE-Value“Protection On”,我正在尝试找出如何添加字符串值“Protection On”在脚本中。我希望根据以下Powershell命令的结果创建一个注册密钥:PS>manage bde-status-cn localhost磁盘卷,可以使用加密方法进行保护:AES 128,扩散保护状态:Protection Off,因此脚本需要提取名为:保护状态:保护关闭/打开,并创建一个调用的变量,即:$ProtectionStatus,然后使用以下命令添加注册表项:New ItemProperty-Path HKLM:\SOFTWARE\Policies\Microsoft\FVE-Name MyTestEntry-PropertyType String-Value“$ProtectionStatus”
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\FVE -Name MyTestEntry -PropertyType String -Value "$ProtectionStatus"