简体   繁体   English

Powershell - 无法解锁 BitLocker,因为 256 个字符的长密码包含带有单双引号的特殊字符

[英]Powershell - Can't unlock BitLocker as 256 characters long password contains special characters with single double quotes

Here's the background and I have no clue beyond this so tell me how to move ahead from this!这是背景,除此之外我没有任何线索,所以请告诉我如何继续前进!

PS C:\> $SecureString = ConvertTo-SecureString "fjuksAS1337" -AsPlainText -Force

PS C:\> Unlock-BitLocker -MountPoint "E:" -Password $SecureString

My password here is:我这里的密码是:

cF;TA" X%jl"\G{d}rcVzNI=Inps#|P,o{~"k<+@?bm)PjQf^\c8EB! (cL.ZyA.v/yYQ#,!#gN'%"VwlNFs)(h\1Uf@cFdr7BU%zDA;&2R_3w3C3td-Nm,^VFE$cF>N{ol0Y~qR2i`Vm%Q@ckh0]#ZE!ijnirg5k?bj\L;88wBhg8QqO^/T64D@O6Q'H"")/I5(d4v7RC`jH=JH+,Zy*TY4MEf~.b7?;';zLEmB>F^S7aBrUfnN&(Vuhjw}Z3w5

As you see it has multiple single and double quotes which breaks the SecureString command output getting nowhere.如您所见,它有多个单引号和双引号,这会破坏 SecureString 命令输出无处可去。

I need to use this password in order to unlock BitLocker drive as the UI throws wrong password error and recovery password of 48 digits is unfortunately lost!我需要使用此密码来解锁 BitLocker 驱动器,因为 UI 会抛出错误的密码错误,并且 48 位的恢复密码很遗憾丢失了!

Please help as I am having no idea here at all!请帮忙,因为我根本不知道这里!

Use a single-quoted here-string.使用单引号此处的字符串。 Anything you put in there won't be escaped in any way.你放在那里的任何东西都不会以任何方式逃脱。

Example例子

$PlainTextPassword = @'
cF;TA" X%jl"\G{d}rcVzNI=Inps#|P,o{~"k<+@?bm)PjQf^\c8EB! (cL.ZyA.v/yYQ#,!#gN'%"VwlNFs)(h\1Uf@cFdr7BU%zDA;&2R_3w3C3td-Nm,^VFE$cF>N{ol0Y~qR2i`Vm%Q@ckh0]#ZE!ijnirg5k?bj\L;88wBhg8QqO^/T64D@O6Q'H"")/I5(d4v7RC`jH=JH+,Zy*TY4MEf~.b7?;';zLEmB>F^S7aBrUfnN&(Vuhjw}Z3w5
'@

$SecureString = ConvertTo-SecureString $PlainTextPassword -AsPlainText -Force

For a quick reference:快速参考:


# verbatim string. Nothing get processed. Single-quotes within the string need to 
# be doubled down.
$sq = 'Hello '' world.'

# Expandable string. Stuff that can be expanded will be.
# Double-quotes within the string need to be doubled down or preceded by a backtick `
$dq = "Hello `" "" world"

# verbatim here string. single-quotes within the string do not need to be escaped
# This is the way to go for multiline strings
$sqh = @'
Hello ' World
'@

# Expandable here string. Double quotes within the string do not need to be escaped.
# This is the way to go for multiline strings
$dqh = @"
Hello " World
"@

Reference参考

About_Quoting_Rules 关于_报价_规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 批次:将带有特殊字符的密码设置为变量 - Batch: Set password with special characters to variable 处理多个 CSV 文件并使用 powershell 删除具有双分号字符的单列中的行 - process multiple CSV file and delete rows in a single column which has double semi colon characters using powershell Bitlocker:锁定或解锁事件 - Bitlocker: Lock or Unlock event Bitlocker脚本解锁驱动器 - Bitlocker script to unlock drive 如何使批处理脚本向外部应用程序提供带有特殊字符的密码? - How can I make a batch script supply a password with special characters to an external application? 如何检查变量是否在批处理文件中包含特殊字符 - how to check if the variable contains special characters in batch file Windows Cmd line sc命令,密码中包含特殊字符 - Windows Cmd line sc command with special characters in password 在 CMD 中使用时如何转义密码中的特殊字符 - How to escape the special characters in a password when using in CMD 如何将 Powershell 中的 Windows 快捷方式创建到文件名中包含特殊字符的文件? - How to create a Windows Shortcut in Powershell to a file with special characters in filename? 如何使用powershell批量重命名文件以删除特殊字符 - How to batch rename files to remove special characters with powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM