powershell - Script to add protection status registry key -


i need create script in powershell following ps command , create registry key in computer\hkey_local_machine\software\policies\microsoft\fve results of "protection status: protection off or on".

ps> manage-bde -status -cn localhost 

see output sample below:

bitlocker drive encryption: configuration tool version 6.1.7601 copyright (c) microsoft corporation. rights reserved.  computer name: localhost  disk volumes can protected 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 diffuser     protection status:    protection off     lock status:          unlocked     identification field: none     key protectors:         tpm 

to determine whether protection on or off:

[string]$protectionstatus  if(@((manage-bde -status -cn localhost) -like '*protection on').count -gt 0){     $protectionstatus = "protection on" }  else {$protectionstatus = "protection off"} 

i'm not sure you're trying do--i'm assuming fve registry key (displayed folder in registry editor). add new string value of "mytestentry" data put $protectionstatus variable above:

new-itemproperty -path hklm:\software\policies\microsoft\fve -name mytestentry -propertytype string -value "$protectionstatus" 

see working registry entries

if doesn't you, please explain want. if need command create string registry entry, output manage-bde command irrelevant. if somehow wanting use output command use in command create registry entry, need clear want parse out , looks after it's in registry.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -