Public/Convertto-TitleCase.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function ConvertTo-TitleCase {
  <#
      .Synopsis
      Convert Text to TitleCase
 
      .EXAMPLE
      ConvertTo-TitleCase -Text 'testing'
 
      .EXAMPLE
      Get-ChildItem -Path D:\temp | Select-Object -ExpandProperty Name | ConvertTo-TitleCase
 
      .INPUTS
      System.String
 
      .OUTPUTS
      System.String
  #>

  [OutputType([String])]
  Param(
    [Parameter(
        Mandatory,
        ValueFromPipeline
    )]
    [String[]]$Text
  )
  Process {
    foreach($Line in $Text){
      [CultureInfo]::CurrentCulture.TextInfo.ToTitleCase($Line)
    }
  }
}