LoremText.psm1
<#
.SYNOPSIS LoremText is a text generator that can be used to create random text strings formatted as paragraphs. .DESCRIPTION LoremText is a text generator that can be used to create random text strings formatted as paragraphs. .PARAMETER Paragraphs Use this parameter to specify the overall number of paragraphs created. If no parameter is specified, a random number between 2 and 9 will be selected. .PARAMETER Sentences Use this parameter to specify the overall number of sentences per paragraph. If no paramter is specified, a random number between 1 and 9 will be selected. .PARAMETER Words Use this parameter to specify the overall number of words per sentence. If no parameter is specified, a random number between 5 and 17 will be selected. #> function LoremText { param ( [int]$Paragraphs, [int]$Sentences, [int]$Words) $TextInfo = (Get-Culture).TextInfo # Seed text words $LoremSeedText = ('a', 'ac', 'accumsan', 'ad', 'adipiscing', 'aenean', 'aliquam', 'aliquet', 'amet', 'ante', 'aptent', 'arcu', 'at', 'auctor', 'augue', 'bibendum', 'blandit', 'Class', 'commodo', 'condimentum', 'congue', 'consectetur', 'consequat', 'convallis', 'cras', 'cubilia', 'cum', 'curabitur', 'curae', 'cursus', 'dapibus', 'diam', 'dictum', 'dictumst', 'dignissim', 'dis', 'dolor', 'donec', 'dui', 'duis', 'egestas', 'eget', 'egetongue', 'eleifend', 'elementum', 'elit', 'enim', 'erat', 'eros', 'est', 'et', 'etiam', 'eu', 'euismod', 'facilisi', 'facilisis', 'fames', 'faucibus', 'felis', 'fermentum', 'feugiat', 'fringilla', 'fusce', 'gravida', 'habitant', 'habitasse', 'hac', 'hendrerit', 'himenaeos', 'iaculis', 'id', 'Imperdiet', 'in', 'inceptos', 'integer', 'interdum', 'ipsum', 'justo', 'lacinia', 'lacus', 'laoreet', 'lectus', 'leo', 'libero', 'ligula', 'litora', 'lobortis', 'Lorem', 'luctus', 'maecenas', 'magna', 'magnis', 'malesuada', 'Massa', 'mattis', 'mauris', 'metus', 'mi', 'molestie', 'mollis', 'Montes', 'morbi', 'mus', 'nam', 'Nascetur', 'natoque', 'nec', 'neque', 'netus', 'nibh', 'nisi', 'nisl', 'non', 'nostra', 'nulla', 'nullam', 'nunc', 'odio', 'orci', 'ornare', 'parturient', 'pellentesque', 'penatibus', 'penultimate', 'per', 'pharetra', 'phasellus', 'placerat', 'platea', 'porta', 'porttitor', 'posuere', 'potenti', 'praesent', 'pretium', 'primis', 'proin', 'pulvinar', 'purus', 'quam', 'quis', 'quisque', 'rabincuis', 'rehbartum', 'rhoncus', 'ridiculus', 'risus', 'Rutrum', 'sagittis', 'sapien', 'scelerisque', 'sed', 'sem', 'semper', 'senectus', 'sit', 'sociis', 'sociosqu', 'sodales', 'sollicitudin', 'suscipit', 'suspendisse', 'taciti', 'tellus', 'tempor', 'tempus', 'tincidunt', 'torquent', 'torqulent', 'tortor', 'tristique', 'turpis', 'ullamcorper', 'ultrices', 'ultricies', 'urna', 'ut', 'varius', 'vehicula', 'vel', 'velit', 'venenatis', 'vestibulum', 'vitae', 'vivamus', 'viverra', 'volutpat', 'vulputate') # Paragraphs per data set $ParagraphMinSeed = Get-Random -Minimum 2 -Maximum 4 $ParagraphMaxSeed = Get-Random -Minimum 5 -Maximum 9 # Minimum number of sentences per paragraph $SentencePerParaMinSeed = Get-Random -Minimum 1 -Maximum 4 $SentencePerParaMaxSeed = Get-Random -Minimum 5 -Maximum 9 # Mininum number of words per sentence $WordsPerSentenceMinSeed = Get-Random -Minimum 5 -Maximum 8 $WordsPerSentenceMaxSeed = Get-Random -Minimum 9 -Maximum 17 $MessageBody = New-Object System.Text.StringBuilder # Generate the number of paragraphs for this data set If (!$Paragraphs) { [int]$Paragraphs = Get-Random -Minimum $ParagraphMinSeed -Maximum $ParagraphMaxSeed } foreach ($p in (1 .. $Paragraphs)) { # Generate the number of sentences per paragraph for this data set If (!$Sentences) { [int]$Sentences = Get-Random -Minimum $SentencePerParaMinSeed -Maximum $SentencePerParaMaxSeed } foreach ($s in (1 .. $Sentences)) { # Generate the number of words per sentence for this data set If (!$Words) { [int]$Words = Get-Random -Minimum $WordsPerSentenceMinSeed -Maximum $WordsPerSentenceMaxSeed } # Create the sentence object $Sentence = New-Object System.Text.StringBuilder # Add words to the sentence Foreach ($w in (1 .. $Words)) { $Sentence.Append(" ").Append((Get-Random -InputObject $LoremSeedText)) | Out-Null } # Add the trailing period, convert to a string, trim the empty space # at the beginning $Sentence.Append(". ") | Out-Null $Sentence = $Sentence.ToString() $Sentence = $Sentence.TrimStart() # Capitalize the first word of the sentence. $Sentence = $Sentence.Substring(0, 1).ToUpper() + $Sentence.SubString(1) # Add the sentence to the email message body text. $MessageBody.Append($Sentence) | Out-Null } # Append two CRLFs to Paragraph $MessageBody.Append("`r`n`r`n") | Out-Null } $MessageBody = $MessageBody.ToString() Return $MessageBody } Export-ModuleMember -Function LoremText |