-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUntitled1.ps1
More file actions
52 lines (42 loc) · 1.04 KB
/
Untitled1.ps1
File metadata and controls
52 lines (42 loc) · 1.04 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function Format-Case{
<#
.Synopsis
Format a given string into upper, lower, or proper case.
.Description
Specify a string and optionally, -U for upper case or -L for lower case. Default behavior is to proper case the string.
.Parameter Text
The string to be modified.
.Parameter L
Optional switch to lower-case the string.
.Parameter U
Optional switch to upper-case the string.
#>
param(
[parameter(Mandatory=$true)]
[string]$Text,
[parameter(Mandatory=$false)]
[switch]$L,
[parameter(Mandatory=$false)]
[switch]$U
)
begin{
[string]$processed = "";
}
process{
if($L)
{
$processed = (Get-Culture).TextInfo.ToLower($Text);
}
elseif($U)
{
$processed = (Get-Culture).TextInfo.ToUpper($Text);
}
else
{
$processed = (Get-Culture).TextInfo.ToTitleCase($Text);
}
}
end{
return $processed;
}
}