How to convert the content of the file into uppercase or lowercase?


To convert the content of the file into the upper case, you need to use the method ToUpper() and to convert into lower case, you need to use ToLower() method.

Upper case example

(Get-Content D:\Temp\PowerShellaliases.txt).ToUpper()

Output

PS C:\WINDOWS\system32> (Get-Content D:\Temp\PowerShellaliases.txt).ToUpper()
COMMANDTYPE     NAME                                               VERSION    SOURCE
-----------     ----                                               -------    ------
ALIAS           % -> FOREACH-OBJECT
ALIAS           ? -> WHERE-OBJECT
ALIAS           AC -> ADD-CONTENT
ALIAS           ASNP -> ADD-PSSNAPIN
ALIAS           CAT -> GET-CONTENT
ALIAS           CD -> SET-LOCATION
ALIAS           CFS -> CONVERTFROM-STRING                          3.1.0.0    MICROSOFT.POWERSHELL.UTILITY
ALIAS           CHDIR -> SET-LOCATION
ALIAS           CLC -> CLEAR-CONTENT
ALIAS           CLEAR -> CLEAR-HOST
ALIAS           CLHY -> CLEAR-HISTORY
ALIAS           CLI -> CLEAR-ITEM
ALIAS           CLP -> CLEAR-ITEMPROPERTY
ALIAS           CLS -> CLEAR-HOST

Lower case example

(Get-Content D:\Temp\PowerShellaliases.txt).ToLower()

Output

PS C:\WINDOWS\system32> (Get-Content D:\Temp\PowerShellaliases.txt).ToLower()
commandtype     name                                               version
-----------     ----                                               -------
alias           % -> foreach-object
alias           ? -> where-object
alias           ac -> add-content
alias           asnp -> add-pssnapin
alias           cat -> get-content
alias           cd -> set-location
alias           cfs -> convertfrom-string                          3.1.0.0
alias           chdir -> set-location
alias           clc -> clear-content
alias           clear -> clear-host
alias           clhy -> clear-history
alias           cli -> clear-item
alias           clp -> clear-itemproperty
alias           cls -> clear-host
alias           clv -> clear-variable
alias           cnsn -> connect-pssession
alias           compare -> compare-object
alias           copy -> copy-item
alias           cp -> copy-item
alias           cpi -> copy-item
alias           cpp -> copy-itemproperty
alias           curl -> invoke-webrequest
alias           cvpa -> convert-path
alias           dbp -> disable-psbreakpoint
alias           del -> remove-item
alias           diff -> compare-object
alias           dir -> get-childitem

Updated on: 16-Mar-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements