powershell 将剪贴板文本转换为哈希表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 将剪贴板文本转换为哈希表相关的知识,希望对你有一定的参考价值。

(gcb) -replace '\],\[',"`n" | % { $_ -replace '(\[|\])','' } | % { $_ -replace ',','=' } | ConvertFrom-StringData 

# 100 Continue
# 101 Switching Protocol
# => @{ "100" = "Continue";"101" = "Switching Protocol" }
(gcb | % { $_ -replace '(\d+) (.*)$', '"$1" = "$2"'} ) -join ';'
(gcb | % { $_ -replace '(\d+) (.*)$', '"$1" = "$2"'} ) -join ';' | % { "@{ $_ }" } | clip

# use $1 in single quotes '$1' not double quotes

以上是关于powershell 将剪贴板文本转换为哈希表的主要内容,如果未能解决你的问题,请参考以下文章

在 Powershell 中将字符串转换为哈希表

cURL 到 PowerShell - 哈希表

使用 Powershell 将 XML 转为哈希表

PowerCLI脚本,利用哈希表对参数进行转换

如何使用PowerShell将UTF-8字符传递给clip.exe而不转换为另一个字符集?

如何在PowerShell中将哈希字符串转换为字节数组?