FormatTools.psm1

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
function Format-Banner
{
    [CmdletBinding()]
    param ( 
        [Parameter(ValueFromRemainingArguments,ValueFromPipeline=$true,position=0,mandatory=$true)]
        [string[]]$strings, 
        [switch]$asObject ,
        [char]$marker = "#"
        )
    BEGIN
    {
        $bit = @( 128, 64, 32, 16, 8, 4, 2, 1 )
        $chars = @(
                @( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),   # ' '
                @( 0x38, 0x38, 0x38, 0x10, 0x00, 0x38, 0x38 ),   # '!'
                @( 0x24, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00 ),   # '"' UNV
                @( 0x28, 0x28, 0xFE, 0x28, 0xFE, 0x28, 0x28 ),   # '#'
                @( 0x7C, 0x92, 0x90, 0x7C, 0x12, 0x92, 0x7C ),   # '$'
                @( 0xE2, 0xA4, 0xE8, 0x10, 0x2E, 0x4A, 0x8E ),   # '%'
                @( 0x30, 0x48, 0x30, 0x70, 0x8A, 0x84, 0x72 ),   # '&'
                @( 0x38, 0x38, 0x10, 0x20, 0x00, 0x00, 0x00 ),   # '''
                @( 0x18, 0x20, 0x40, 0x40, 0x40, 0x20, 0x18 ),   # '('
                @( 0x30, 0x08, 0x04, 0x04, 0x04, 0x08, 0x30 ),   # ')'
                @( 0x00, 0x44, 0x28, 0xFE, 0x28, 0x44, 0x00 ),   # '*'
                @( 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00 ),   # '+'
                @( 0x00, 0x00, 0x00, 0x38, 0x38, 0x10, 0x20 ),   # ','
                @( 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00 ),   # '-'
                @( 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38 ),   # '.'
                @( 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 ),   # '/'
                @( 0x38, 0x44, 0x82, 0x82, 0x82, 0x44, 0x38 ),   # '0'
                @( 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x7C ),   # '1'
                @( 0x7C, 0x82, 0x02, 0x7C, 0x80, 0x80, 0xFE ),   # '2'
                @( 0x7C, 0x82, 0x02, 0x7C, 0x02, 0x82, 0x7C ),   # '3'
                @( 0x80, 0x84, 0x84, 0x84, 0xFE, 0x04, 0x04 ),   # '4'
                @( 0xFE, 0x80, 0x80, 0xFC, 0x02, 0x82, 0x7C ),   # '5'
                @( 0x7C, 0x82, 0x80, 0xFC, 0x82, 0x82, 0x7C ),   # '6'
                @( 0xFC, 0x84, 0x08, 0x10, 0x20, 0x20, 0x20 ),   # '7'
                @( 0x7C, 0x82, 0x82, 0x7C, 0x82, 0x82, 0x7C ),   # '8'
                @( 0x7C, 0x82, 0x82, 0x7E, 0x02, 0x82, 0x7C ),   # '9'
                @( 0x10, 0x38, 0x10, 0x00, 0x10, 0x38, 0x10 ),   # ':'
                @( 0x38, 0x38, 0x00, 0x38, 0x38, 0x10, 0x20 ),   # ';'
                @( 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08 ),   # '<'
                @( 0x00, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0x00 ),   # '=' UNV.
                @( 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20 ),   # '>'
                @( 0x7C, 0x82, 0x02, 0x1C, 0x10, 0x00, 0x10 ),   # '?'
                @( 0x7C, 0x82, 0xBA, 0xBA, 0xBC, 0x80, 0x7C ),   # '@'
                @( 0x10, 0x28, 0x44, 0x82, 0xFE, 0x82, 0x82 ),   # 'A'
                @( 0xFC, 0x82, 0x82, 0xFC, 0x82, 0x82, 0xFC ),   # 'B'
                @( 0x7C, 0x82, 0x80, 0x80, 0x80, 0x82, 0x7C ),   # 'C'
                @( 0xFC, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFC ),   # 'D'
                @( 0xFE, 0x80, 0x80, 0xF8, 0x80, 0x80, 0xFE ),   # 'E'
                @( 0xFE, 0x80, 0x80, 0xF8, 0x80, 0x80, 0x80 ),   # 'F'
                @( 0x7C, 0x82, 0x80, 0x9E, 0x82, 0x82, 0x7C ),   # 'G'
                @( 0x82, 0x82, 0x82, 0xFE, 0x82, 0x82, 0x82 ),   # 'H'
                @( 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38 ),   # 'I'
                @( 0x02, 0x02, 0x02, 0x02, 0x82, 0x82, 0x7C ),   # 'J'
                @( 0x84, 0x88, 0x90, 0xE0, 0x90, 0x88, 0x84 ),   # 'K'
                @( 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFE ),   # 'L'
                @( 0x82, 0xC6, 0xAA, 0x92, 0x82, 0x82, 0x82 ),   # 'M'
                @( 0x82, 0xC2, 0xA2, 0x92, 0x8A, 0x86, 0x82 ),   # 'N'
                @( 0xFE, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFE ),   # 'O'
                @( 0xFC, 0x82, 0x82, 0xFC, 0x80, 0x80, 0x80 ),   # 'P'
                @( 0x7C, 0x82, 0x82, 0x82, 0x8A, 0x84, 0x7A ),   # 'Q'
                @( 0xFC, 0x82, 0x82, 0xFC, 0x88, 0x84, 0x82 ),   # 'R'
                @( 0x7C, 0x82, 0x80, 0x7C, 0x02, 0x82, 0x7C ),   # 'S'
                @( 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 ),   # 'T'
                @( 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7C ),   # 'U'
                @( 0x82, 0x82, 0x82, 0x82, 0x44, 0x28, 0x10 ),   # 'V'
                @( 0x82, 0x92, 0x92, 0x92, 0x92, 0x92, 0x6C ),   # 'W'
                @( 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82 ),   # 'X'
                @( 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10 ),   # 'Y'
                @( 0xFE, 0x04, 0x08, 0x10, 0x20, 0x40, 0xFE ),   # 'Z'
                @( 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7C ),   # '['
                @( 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 ),   # '\'
                @( 0x7C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x7C ),   # ']'
                @( 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00 ),   # '^'
                @( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE ),   # '_'
                @( 0x00, 0x38, 0x38, 0x10, 0x08, 0x00, 0x00 ),   # '`'
                @( 0x00, 0x18, 0x24, 0x42, 0x7E, 0x42, 0x42 ),   # 'a'
                @( 0x00, 0x7C, 0x42, 0x7C, 0x42, 0x42, 0x7C ),   # 'b'
                @( 0x00, 0x3C, 0x42, 0x40, 0x40, 0x42, 0x3C ),   # 'c'
                @( 0x00, 0x7C, 0x42, 0x42, 0x42, 0x42, 0x7C ),   # 'd'
                @( 0x00, 0x7E, 0x40, 0x7C, 0x40, 0x40, 0x7E ),   # 'e'
                @( 0x00, 0x7E, 0x40, 0x7C, 0x40, 0x40, 0x40 ),   # 'f'
                @( 0x00, 0x3C, 0x42, 0x40, 0x4E, 0x42, 0x3C ),   # 'g'
                @( 0x00, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42 ),   # 'h'
                @( 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 ),   # 'i'
                @( 0x00, 0x02, 0x02, 0x02, 0x02, 0x42, 0x3C ),   # 'j'
                @( 0x00, 0x42, 0x44, 0x78, 0x48, 0x44, 0x42 ),   # 'k'
                @( 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E ),   # 'l'
                @( 0x00, 0x42, 0x66, 0x5A, 0x42, 0x42, 0x42 ),   # 'm'
                @( 0x00, 0x42, 0x62, 0x52, 0x4A, 0x46, 0x42 ),   # 'n'
                @( 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C ),   # 'o'
                @( 0x00, 0x7C, 0x42, 0x42, 0x7C, 0x40, 0x40 ),   # 'p'
                @( 0x00, 0x3C, 0x42, 0x42, 0x4A, 0x44, 0x3A ),   # 'q'
                @( 0x00, 0x7C, 0x42, 0x42, 0x7C, 0x44, 0x42 ),   # 'r'
                @( 0x00, 0x3C, 0x40, 0x3C, 0x02, 0x42, 0x3C ),   # 's'
                @( 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08 ),   # 't'
                @( 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C ),   # 'u'
                @( 0x00, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18 ),   # 'v'
                @( 0x00, 0x42, 0x42, 0x42, 0x5A, 0x66, 0x42 ),   # 'w'
                @( 0x00, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42 ),   # 'x'
                @( 0x00, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08 ),   # 'y'
                @( 0x00, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E ),   # 'z'
                @( 0x38, 0x40, 0x40, 0xC0, 0x40, 0x40, 0x38 ),   # '{'
                @( 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 ),   # '|'
                @( 0x38, 0x04, 0x04, 0x06, 0x04, 0x04, 0x38 ),   # '}'
                @( 0x60, 0x92, 0x0C, 0x00, 0x00, 0x00, 0x00 )    # '~'
        );
        $o = new-object -TypeName psobject
        $o | add-member -MemberType NoteProperty -Name OriginalStrings -Value @()
        $o.psobject.typenames.Insert(0,"Banner")
    }
    PROCESS
    {
        $o.OriginalStrings += $strings
        $output = ""
        $length = "$strings".length
        $width = [math]::floor(($host.ui.rawui.buffersize.width-1)/8)
        # check and bail if a string is too long
        foreach ( $substring in $strings)
        {
            if ($substring.length -gt $width)
            {
                throw "strings must be less than $width characters"
            }
        }

        foreach($substring in $strings)
        {
            for($r = 0; $r -lt 7; $r++)
            {
                foreach($c in $substring.ToCharArray())
                {
                    $bitmap = 0
                    if ( ($c -ge " ") -and ($c -le [char]"~"))
                    {
                        $offset = ([int]$c) - 32
                        $bitmap = $chars[$offset][$r]
                    }
                    for($c=0;$c -lt 8;$c++)
                    {
                        if ( $bitmap -band $bit[$c] ) { $output += $marker } else { $output += " " }
                    }
                }
                $output += "`n"
            }
        }
        #$output
        $sb = $executioncontext.invokecommand.NewScriptBlock("'$output'")
        $o | add-member -force -MemberType ScriptMethod -Name ToString -Value $sb
        if ( $asObject )
        {
            $o
        }
        else
        {
            $o.ToString()
        }
    }
}

function New-TableFormat
{
    [CmdletBinding()]
    param ( 
        [Parameter(Mandatory=$true,ValueFromPipeline=$true)]$object, 
        [Parameter(Mandatory=$true,Position=0)][object[]]$property, 
        [Parameter(Mandatory=$false,Position=1)][string]$group, 
        [switch]$auto, $name, 
        [switch]$force ,
        [switch]$StandAlone
        )
    Begin
    {
        $TypeCollection = @{}
    }
    Process
    {
        if ( ! $TypeCollection.ContainsKey($object.gettype().Fullname))
        {
            $TypeCollection[$object.gettype().FullName] = 1
        }
    }
    End
    {
        $SelectionSet = $null
        if ( $TypeCollection.Keys.Count -gt 1 )
        {
            $SelectionSetName = ($typeCollection.keys |sort-object| foreach-object { $_.split(".")[-1] }) -join "_"
            $SelectionSet = "<SelectionSets>",
                " <SelectionSet>",
                " <Name>${SelectionSetName}</Name>",
                " <Types>"
            $SelectionSet += $TypeCollection.Keys | foreach-object{ " <TypeName>$_</TypeName>" }
            $SelectionSet += " </Types>", " </SelectionSet>", "</SelectionSets>"

        }
        if ( $StandAlone )
        {
            "<Configuration>"
        }
        if ( $SelectionSet )
        {
            $SelectionSet
        }

        if ( $StandAlone )
        {
            " <ViewDefinitions>"
        }
        if ( $name )
        {
            $TN = $name
            $TypeNameSelector = "<TypeName>${TN}</TypeName>`n"
        }
        elseif ( $object -and ($SelectionSet -eq $null) )
        {
            if ( $object -is "PSObject")
            {
                $TN = $object.psobject.typenames[0]
            }
            else
            {
                $TN = $object.gettype().fullname
            }
            $TypeNameSelector = "<TypeName>${TN}</TypeName>`n"
        }
        elseif ( $SelectionSet -ne $null )
        {
            $TN = $SelectionSetName
            $TypeNameSelector = "<SelectionSetName>${SelectionSetName}</SelectionSetName>"
        }
        # skip this check for now, because we added support for hashtables,
        # we need to just keep going
        #foreach($p in $property)
        #{
        # if(! $object.psobject.members.item($p) -and ! $force)
        # {
        # $property = $property | ?{ $_ -notmatch $p }
        # write-host -for red "$p does not exist, skipping"
        # }
        #}
        $NAME = $TN.split(".")[-1]
        $sb = new-object -TypeName System.Text.StringBuilder
        [void]$sb.Append(" <View>`n")
        [void]$sb.Append(" <Name>${Name}Table</Name>`n")
        [void]$sb.Append(" <ViewSelectedBy>`n")
        [void]$sb.Append(" ${TypeNameSelector}`n")
        [void]$sb.Append(" </ViewSelectedBy>`n")
        if ( $group )
        {
            [void]$sb.Append(" <GroupBy>`n")
            [void]$sb.Append(" <PropertyName>$group</PropertyName>`n")
            [void]$sb.Append(" <Label>$group</Label>`n")
            [void]$sb.Append(" </GroupBy>`n")
        }
        [void]$sb.Append(" <TableControl>`n")
        if ( $auto ) 
        { 
        [void]$sb.Append(" <AutoSize />`n") 
        }
        [void]$sb.Append(" <TableHeaders>`n")
        ###
        ### HEADER
        ###
        foreach($p in $property)
        {
            if ( $p -is "string" )
            {
                [void]$sb.Append(" <TableColumnHeader><Label>${p}</Label></TableColumnHeader>`n")
            }
            elseif ( $p -is "scriptblock" )
            {
                [void]$sb.Append(" <TableColumnHeader>`n")
                [void]$sb.Append(" <Label>" + $p.ToString() + "</Label>`n")
                [void]$sb.Append(" </TableColumnHeader>`n")
            }
            elseif ( $p -is "hashtable" )
            {
                $Label = $p.keys | ?{$_ -match "^L" }
                if ( ! $Label )
                {
                    throw "need Name or Label Key"
                }
                [void]$sb.Append(" <TableColumnHeader>`n")
                [void]$sb.Append(" <Label>" + $p.$label + "</Label>`n")
                $Width = $p.Keys |?{$_ -match "^W"}
                if ( $Width )
                {
                    [void]$sb.Append(" <Width>" + $p.$Width + "</Width>`n")
                }
                $Align = $p.Keys |?{$_ -match "^A"}
                if ( $Align )
                {
                    [void]$sb.Append(" <Alignment>" + $p.$align + "</Alignment>`n")
                }
                [void]$sb.Append(" </TableColumnHeader>`n")
                # write-host -for red ("skipping " + $p.Name + " for now")
            }
        }
        [void]$sb.Append(" </TableHeaders>`n")
        ###
        ### ROWS
        ###
        [void]$sb.Append(" <TableRowEntries>`n")
        [void]$sb.Append(" <TableRowEntry>`n")
        [void]$sb.Append(" <TableColumnItems>`n")
        foreach($p in $property)
        {
            if ( $p -is "string" )
            {
                [void]$sb.Append(" <TableColumnItem><PropertyName>${p}</PropertyName></TableColumnItem>`n")
            }
            elseif ( $p -is "Scriptblock" )
            {
                [void]$sb.Append(" <TableColumnItem><ScriptBlock>" + $p.tostring() + "</ScriptBlock></TableColumnItem>`n") 
            }
            elseif ( $p -is "hashtable" )
            {
                $Name = $p.Keys | ?{$_ -match "^N" }
                if ( $Name ) 
                { 
                    [void]$sb.Append(" <TableColumnItem><PropertyName>" + $p.$Name + "</PropertyName></TableColumnItem>`n") 
                }
                $Expression = $p.Keys |?{$_ -match "^E" }
                if ( $Expression )
                {
                    if ( $p.$Expression -is "string" )
                    {
                        [void]$sb.Append(" <TableColumnItem><PropertyName>" + $p.$Expression + "</PropertyName></TableColumnItem>`n") 
                    }
                    elseif ( $p.$Expression -is "scriptblock" )
                    {
                        [void]$sb.Append(" <TableColumnItem><ScriptBlock>" + $p.$Expression + "</ScriptBlock></TableColumnItem>`n") 
                    }
                }
                else 
                { 
                    [void]$sb.Append(" <TableColumnItem><PropertyName>" + $p.Label + "</PropertyName></TableColumnItem>`n") 
                }
            }
        }
        [void]$sb.Append(" </TableColumnItems>`n")
        [void]$sb.Append(" </TableRowEntry>`n")
        [void]$sb.Append(" </TableRowEntries>`n")
        [void]$sb.Append(" </TableControl>`n")
        [void]$sb.Append(" </View>`n")
        $sb.ToString()
        if ( $StandAlone )
        {
            " </ViewDefinitions>"
            "</Configuration>"
        }
    }
}

function Format-String
{
    [CmdletBinding()]
    param ( [string]$string, [int]$width = 76 , [switch]$indent, [int]$padw = 0, [int]$tabWidth = 4)
    END
    {
        $string = $string.Replace("`n", " ").Replace(" ", " ")
        $columns = $width
        $text = $string -split "[ `t]"

        $pad = " " * $padw
        $lines = @()
        $l = 0
        $initialTab = ""
        if ( $indent )
        {
            $initialTab = " " * $tabWidth
        }

        $line = $initialTab + $pad
        #"01234567890123456789012345678901234567890123456789"
        foreach ( $word in $text )
        {
            if ( $word.length -gt $columns)
            {
                write-warning whoops
                $wordFragment = $word
                while($wordFragment.Length -gt $columns)
                {
                    $sub = $columns - ($line.length + 1)
                    $line += $wordFragment.Substring(0,$sub)
                    $lines += $line.TrimEnd()
                    $line = $pad
                    $wordFragment = $wordFragment.SubString($sub)
                }
                $line = $wordFragment + " "
            }
            elseif ( $word.length + 1 + $line.length -gt $columns)
            {
                $lines += $line.TrimEnd()
                $line = $pad + $word + " "
            }
            else
            {
                $line += $word + " "
            }
            <#
            if (($line.length + $word.length + 1) -gt $columns )
            {
                 
            }
                if ( ($line.length + $word.length + 1 ) -gt $columns )
                {
                        #"big " + $word
                        $lines += ($pad + $line)
                        $lines += ($pad + $word)
                        $line = ""
                        $l = 0
                }
# elseif(($pad.length + $l + $word.length + 1) -lt $columns)
# {
# #"ok " + $word
# $line += $word + " "
# $l += $word.length + 1
# }
                else
                {
                        #"cr " + $word
                        $lines += ($pad + $line)
                        $line = $word + " "
                        $l = $line.length
                }
                #>

        }
        $lines += $line.TrimEnd()
        #$lines | %{ "${pad}${_}" }
        # if ( ! $indent )
        #{
        # $lines[0] = $lines[0].Trim()
        # }
        $lines
    }
}

function Get-Lorem
{
    [CmdletBinding()]
    param ([int]$count = 14 )
    END
    {
    $lorem = "Lorem","ipsum","dolor","sit","amet,","consectetaur","adipisicing","elit,",
        "sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna",
        "aliqua.","Ut","enim","ad","minim","veniam,","quis","nostrud","exercitation",
        "ullamco","laboris","nisi","ut","aliquip","ex","ea","commodo","consequat.","Duis",
        "aute","irure","dolor","in","reprehenderit","in","voluptate","velit","esse","cillum",
        "dolore","eu","fugiat","nulla","pariatur.","Excepteur","sint","occaecat","cupidatat",
        "non","proident,","sunt","in","culpa","qui","officia","deserunt","mollit","anim","id",
        "est","laborum.","Sed","ut","perspiciatis","unde","omnis","iste","natus","error",
        "sit","voluptatem","accusantium","doloremque","laudantium,","totam","rem","aperiam,",
        "eaque","ipsa","quae","ab","illo","inventore","veritatis","et","quasi","architecto",
        "beatae","vitae","dicta","sunt","explicabo.","Nemo","enim","ipsam","voluptatem","quia",
        "voluptas","sit","aspernatur","aut","odit","aut","fugit,","sed","quia","consequuntur","magni",
        "dolores","eos","qui","ratione","voluptatem","sequi","nesciunt.","Neque","porro","quisquam",
        "est,","qui","dolorem","ipsum","quia","dolor","sit","amet,","consectetur,","adipisci",
        "velit,","sed","quia","non","numquam","eius","modi","tempora","incidunt","ut","labore","et",
        "dolore","magnam","aliquam","quaerat","voluptatem.","Ut","enim","ad","minima","veniam,",
        "quis","nostrum","exercitationem","ullam","corporis","suscipit","laboriosam,","nisi","ut","aliquid",
        "ex","ea","commodi","consequatur?","Quis","autem","vel","eum","iure","reprehenderit","qui",
        "in","ea","voluptate","velit","esse","quam","nihil","molestiae","consequatur,","vel",
        "illum","qui","dolorem","eum","fugiat","quo","voluptas","nulla","pariatur?",
        "At","vero","eos","et","accusamus","et","iusto","odio","dignissimos","ducimus","qui",
        "blanditiis","praesentium","voluptatum","deleniti","atque","corrupti","quos","dolores","et",
        "quas","molestias","excepturi","sint","occaecati","cupiditate","non","provident,","similique",
        "sunt","in","culpa","qui","officia","deserunt","mollitia","animi,","id","est","laborum",
        "et","dolorum","fuga.","Et","harum","quidem","rerum","facilis","est","et","expedita",
        "distinctio.","Nam","libero","tempore,","cum","soluta","nobis","est","eligendi","optio",
        "cumque","nihil","impedit","quo","minus","id","quod","maxime","placeat","facere","possimus,",
        "omnis","voluptas","assumenda","est,","omnis","dolor","repellendus.","Temporibus","autem",
        "quibusdam","et","aut","officiis","debitis","aut","rerum","necessitatibus","saepe","eveniet",
        "ut","et","voluptates","repudiandae","sint","et","molestiae","non","recusandae.","Itaque","earum",
        "rerum","hic","tenetur","a","sapiente","delectus,","ut","aut","reiciendis","voluptatibus","maiores",
        "alias","consequatur","aut","perferendis","doloribus","asperiores","repellat."

    $r = get-random -input $lorem -count $count
    $s = $r -join " "
    ([char]::ToUpper($s[0]) + $s.substring(1) + ".")
    }

}