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

时间:2015-06-18 18:20:44

标签: powershell

我需要使用以下PS命令在PowerShell中创建脚本,并在Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\FVE中创建一个注册表项,其结果为“保护状态:保护关闭或开启”。

PS> manage-bde -status -cn localhost

参见下面的输出示例:

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

1 个答案:

答案 0 :(得分:0)

确定保护是打开还是关闭:

[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"

请参阅Working with Registry Entries

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

相关问题