2024-11-06

PowerShell UTF-8 to Base64 Encode / Decode

[string]$StringToEncode="編碼的字串"
$EncodedString=[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($StringToEncode))
write-host "Encoded String:" $EncodedString

$DecodedString=[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($EncodedString))
write-host "Decoded String:" $DecodedString

PowerShell 將字串單字第一個字母轉換為大寫,其他小寫

PowerShell 將字串單字第一個字母轉換為大寫,其他小寫

$String = ('this is a book');
(Get-Culture).TextInfo.ToTitleCase( $String.ToLower() )