如何将文件内容转换为大写或小写?
要将文件的内容转换为大写,需要使用ToUpper()方法,而要转换为小写,则需要使用ToLower()方法。
大写示例
(Get-Content D:\Temp\PowerShellaliases.txt).ToUpper()
输出结果
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
小写的例子
(Get-Content D:\Temp\PowerShellaliases.txt).ToLower()
输出结果
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