「PowerShell」ToUpperメソッドで英字の小文字を大文字にするサンプル

環境
Windows 10 Home 64bit
Windows PowerShell 5.1.19041.1682

構文
文字列.ToUpper()
ToUpperメソッドを使って、英字の小文字を大文字にします。
英字の全角の小文字も全角の大文字に変換されます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$strA = "arkgame"
Write-Host ($strA.ToUpper())
$strB = "Arkgame"
Write-Host ($strB.ToUpper())
$strC = "study"
Write-Host ($strC.ToUpper())
$strD = "データたろう"
Write-Host ($strD.ToUpper())
$strA = "arkgame" Write-Host ($strA.ToUpper()) $strB = "Arkgame" Write-Host ($strB.ToUpper()) $strC = "study" Write-Host ($strC.ToUpper()) $strD = "データたろう" Write-Host ($strD.ToUpper())
$strA =  "arkgame"
Write-Host ($strA.ToUpper()) 

$strB =  "Arkgame"
Write-Host ($strB.ToUpper()) 

$strC =  "study"
Write-Host ($strC.ToUpper()) 

$strD =  "データたろう"
Write-Host ($strD.ToUpper())

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\study\skill\powershell> ./test02.ps1
ARKGAME
ARKGAME
STUDY
データたろう
PS C:\study\skill\powershell> ./test02.ps1 ARKGAME ARKGAME STUDY データたろう
PS C:\study\skill\powershell> ./test02.ps1
ARKGAME
ARKGAME
STUDY
データたろう

 

PowerShell

Posted by arkgame