2024-11-27

查詢 Microsoft Graph Powershell Command 需要的權限

查詢 Microsoft Graph Powershell Command Permission Requirement

 (Find-MgGraphCommand -Command Command-Let).permissions

2024-11-18

將 Hyper-V VM 的 GUID 寫到 Notes 裡方便查詢

將 Hyper-V VM 的 GUID 寫到 Notes 裡方便查詢:

$VMs = (Get-VM | Select-Object VMName,VMId);
foreach ($VM in $VMs) {
Set-VM -Name $VM.VMName -Notes ('GUID: ' + $VM.VMId)
};





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() )