<# .Synopsis Used to preveiw bbcode in html format. .DESCRIPTION Converts data to HTML output, creates a temporary file and opens it then removes the temporay file. .EXAMPLE Get-PreveiwHTML -Data $Data .INPUTS $Data - psobject or unformated output of cmdlet e.g. no format-table or format-list. Or import from CSV file. $Green - Colour text green $Red - Colour text red $List - List formate for HTML. $CaseSensitivity - enables case sensativity for find and replace for colouring text. .OUTPUTS To screen, no vars. .NOTES Function Version = 0.6 Updated = 12/04/2015 Author = Mark Wichall #> Function Get-PreviewHTML($Data,[String]$Green,[String]$Red,[Switch]$List,[Switch]$CaseSensitivity) { Write-Host "`nGenerating HTML preview..." -NoNewline $HTMLtmp = $Data If ($List) { $HTMLtmp = $HTMLtmp | ConvertTo-HTML -as "list" } Else { $HTMLtmp = $HTMLtmp | ConvertTo-HTML } $HTMLtmp = $HTMLtmp | foreach {$_ -replace "","
"}` | foreach {$_ -replace "","


"}; [Switch]$Colour = $Null [Switch]$ColourError = $Null #Check if Green and Red have values If (($Green.length -ne 0) -and ($Red.length -ne 0)) { #Check if Green and Red values are unique with no overlap. IF ($CaseSensitivity) { If (($Red -clike $Green) -or ($Red -clike "*$Green*") -or ($Green -clike "*$Red*")) { $Colour = $False $ColourError = $True } Else { $Colour = $True } } Else { If (($Red -like $Green) -or ($Red -like "*$Green*") -or ($Green -like "*$Red*")) { $Colour = $False $ColourError = $True } Else { $Colour = $True } } } Else { $Colour = $True } If ($Colour) { #Colour Green Text If (($Green) -and (!$CaseSensitivity)) { $HTMLtmp = $HTMLtmp | foreach {If ($_ -like "*$Green*"){$_ -replace "$Green","$Green"} ELSE {$_}} } ElseIF (($Green) -and ($CaseSensitivity)) { $HTMLtmp = $HTMLtmp | foreach {If ($_ -clike "*$Green*"){$_ -creplace "$Green","$Green"} ELSE {$_}} } #Colour Red Text If (($Red) -and (!$CaseSensitivity)) { $HTMLtmp = $HTMLtmp | foreach {If ($_ -like "*$Red*"){$_ -replace "$Red","$Red"} ELSE {$_}} } ElseIF (($Red) -and ($CaseSensitivity)) { $HTMLtmp = $HTMLtmp | foreach {If ($_ -clike "*$Red*"){$_ -creplace "$Red","$Red"} ELSE {$_}} } } If ($ColourError) { $HTMLTop = @" HTML preveiw of BBCode

This is a HTML preveiw of the BBCode conversion.

Error - Values for Green and Red overlap - They must be unique.

"@ $HTMLBottom = @"

Error - Values for Green and Red overlap - They must be unique.

This is a HTML preveiw of the BBCode conversion.

"@ } Else { $HTMLTop = @" HTML preveiw of BBCode

This is a HTML preveiw of the BBCode conversion.

"@ $HTMLBottom = @"

This is a HTML preveiw of the BBCode conversion.

"@ } $HTML = $Null $HTML = $HTMLTop $HTML = $HTML + $HTMLtmp $HTML = $HTML + $HTMLBottom $tempFile = $Null $tempFile = [io.path]::GetTempFileName() | Rename-Item -NewName { $_ -replace 'tmp$', 'html' } –PassThru; #$HTML | out-file -filePath $tempFile | Out-Null; out-file -filePath $tempFile -inputobject $HTML | Out-Null; Invoke-Item $tempFile Write-Host "..Complete." Return $tempFile } <# .Synopsis Title used when run interactivly. #> Function Get-Title ($Ver,$Author) { $Title = @" csv,csv, csv,csv, csv, csv, ,,>> [table][b] [table][b] csv, c, csv, csv, csv, ,,,>> [tr] [/tr] [tr] [/tr] csv, csv,csv, csv, csv, ,,,>>> [tr][/tr] [tr][/tr] csv, c, csv, csv,csv ,,,>> [tr] [/tr] [tr] [/tr] csv,csv, csv,csv, csv, ,,>> [/table][b] [/table][b] Version = $Ver Author = $Author "@ Write-Host " " Write-Host $Title -ForegroundColor Cyan } <# .Synopsis Convert powershell output or CSV files to bbcode table for use in tickets. .DESCRIPTION Function to convert powershell cmdlet, object output, CSV files, PSO or array of PSO's to a bbcode table, to allow direct pasting of powershell output into tickets e.g. core. .EXAMPLE Var to BBcode - Example oneliner to get resources in a cluster and add result to data variable. Then call with the var to return bbcode table. Import-module failoverclusters $Data = Get-Clustergroup | Select-Object Name,OwnerNode,State ConvertTo-BBCode -Data $Data .EXAMPLE CSV to BBCode - Example oneliner to get resources in a cluster output to a CSV file. Then import the CSV file into the function and output bbcode table. Tested with Other CSV files as well. Import-module failoverclusters Get-Clustergroup | Select-Object Name,OwnerNode, State | Export-csv -path c:\rs-pkgs\ClusterResources.csv ConvertTo-BBCode -CSV "c:\rs-pkgs\ClusterResources.csv" .EXAMPLE CSV to BBCode - Example oneliner which promots for CSV file to convert to BBcode. ConvertTo-BBCode -CSVIn .EXAMPLE BBCode in List Format - Example oneliner to get resources in a cluster output then display as a BBCode table list Import-module failoverclusters $Data = Get-Clustergroup | Select-Object Name,OwnerNode, State ConvertTo-BBCode -Data $Data -list .EXAMPLE Colour text Red that matches a string $Data = Get-Service | Where-Object {$_.Name -Like "A*"} | Select-Object Name,DisplayName,Status ConvertTo-BBCode -Data $Data -ErrorText "Stopped" .EXAMPLE Colour text Red and Green that matches a string $Data = Get-Service | Where-Object {$_.Name -Like "A*"} | Select-Object Name,DisplayName,Status ConvertTo-BBCode -Data $Data -Red "Stopped" -Green "Running" .EXAMPLE Colour text that matches a string & Case sensativity. Allows more control of find and replace for colouring text. uses the switch -casesensitivity $Data = Get-Service | Where-Object {$_.Name -Like "A*"} | Select-Object Name,DisplayName,Status ConvertTo-BBCode -Data $Data -Red "Stopped" -Green "Running" -casesensitivity .EXAMPLE Veiw a HTML preveiw of the BBCode output. uses the switch -Preveiw $Data = Get-Service | Where-Object {$_.Name -Like "A*"} | Select-Object Name,DisplayName,Status ConvertTo-BBCode -Data $Data -Red "Stopped" -Green "Running" -casesensitivity -Preveiw .EXAMPLE Output switches for both PoSH and CSV to BBCode. -List = Output BBcode in a list format -Clip = Output to clipboard -Grid = Displays content in outgrid. Can be pasted from outgrid to ticket as lond as data not modified e.g. flitered. -Preveiw = Previews the output in HTML. -NoReturn = Stops function returning result. -OutputMessage = Display content of input var $Data and message, same as oneliner version of code. ConvertTo-BBCode -CSV "c:\rs-pkgs\ClusterResources.csv" -Clip -Grid -NoReturn -OutputMessage .INPUTS $Data - psobject or unformated output of cmdlet e.g. no format-table or format-list. $CSV - [String] - path and file name to csv file to convert. $CSVIn - [Switch] - Prompt for csv file to convert. $List - [Switch] - Changes format of the table to a list table. $ErrorText [String]/Red[String] - Text to colour red if match found. Sends data to $Red as ErrorText is depricated. $Green - Text to colour red if match found. Sends data to $Red as ErrorText is depricated. $Grid [Switch] - output to Out-Grid. $Clip [Switch] - output to clipboard e.g. clip.exe $NoReturn [Switch] - Stops result being returned from function e.g. the bbcode output. $OutputMessage [Switch] - Output message to screen listing content of input var $Data. $CaseSensitivity [Switch] - Enable case sensativity for find and replace for colouring text .OUTPUTS $BBTable - Array sting bbcode output from function. To screen, to clipboard or to outgrrid using switches -OutGrid, -Screen, -Clip .NOTES Powershell Version 2 required - Parameter Sets is a V2 feature. Allway preveiw output in core before updating a ticket. Option to output to outgrid added as it's usefull for perveiwing output. Core has a limited update size Core = Comments have a size limit of 32K. So be aware of this when using large PoSH queries and csv's. Function Version = 1.8 Updated = 15/4/2015 Author = Mark Wichall #> Function ConvertTo-BBCode { [CmdletBinding(DefaultParametersetName="ParameterSet1")] Param ( # Input var containing unformated data to be converted to BBcode e.g. psobject. [Parameter(ParameterSetName='ParameterSet1', Position=0)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] $Data, # Path and File name of CSV file to import and convert to BBcode e.g. C:\rs-pkgs\test.csv. [Parameter(ParameterSetName='ParameterSet2', Position=0)] [AllowNull()] [AllowEmptyString()] [String] $CSV, # Prompts user for Path and File name of CSV file to import and convert to BBcode. [Parameter(ParameterSetName='ParameterSet3', Position=0)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [Switch] $CSVIn, # Text to colour Red [Parameter(Position=1)] [Alias("Red")] [String] $ErrorText, # Display output in Out-gridveiw. [Parameter(Position=2)] [Switch] $List, # Changes format of table to a list. [Parameter(Position=3)] [Switch] $Grid, # Send output to clipboard. [Parameter(Position=4)] [Switch] $Clip, # Stop function returing result. [Parameter(Position=5)] [Switch] $NoReturn, # Outputs message to screen and content of $Data [Parameter(Position=6)] [Switch] $OutputMessage, # Preveiws the output in HTML [Parameter(Position=7)] [Switch] $Preview, # Don't want to loop code with $CSVin set to true [Parameter(Position=8)] [Switch] $NoLoop, # Enable case sensativity for find and replace for colouring text [Parameter(Position=9)] [Switch] $CaseSensitivity, # Text to colour Green [Parameter(Position=10)] [String] $Green ) $psver = $psversiontable.psversion.major If ($psver -lt 2) { Write-Host "Powershell version $psver installed. Powershell 2.0 or above reqiured. Exiting function." -forgroundcolor Red Break } [Switch]$ExitRun = $true [Array]$TempFiles = $Null Do { $Import = $Null If ($CSVIn) { If ($NoLoop -eq $True) { $ExitRun = $True } Else { $ExitRun = $False } Get-Title -Ver "1.7" -Author "Mark Wichall" [Switch]$ValidPath = $False #Sets loging source $Global:Source = "RunFromShortcut" Do { $CSVinput = Read-Host "`nEnter the CSV file path you want to convert to BBCode (Drag and drop csv file)`n" $CSVinput = $CSVinput -replace '"', '' IF ($CSVinput.length -eq 0) { Write-Host "No path entered. Enter a CSV path!`n" -ForegroundColor Red Continue } If (Test-Path $CSVinput -PathType Leaf) { $ValidPath = $True $Import = $CSVinput } Else { Write-Host -ForegroundColor Yellow ".CSV File not found. Path = $CSVinput `n" Continue } } Until ($ValidPath) } If ($CSV) { If (Test-Path $CSV -PathType Leaf) { $Import = $CSV } Else { Write-Host -ForegroundColor Yellow "Path to file not found. Path = $CSV `n" Break } } If ($Import) { Try { $Data = import-csv -path $Import } Catch { Write-Host -ForegroundColor Red "Error importing CSV file from path. $CSV `n" Break } } If ($Data.length -eq 0) { Write-Host -ForegroundColor Red "Error Data parameter is null or empty. `n" Break } #Outputs to screen previewing the data like the oneliner version. If ($OutputMessage) { Write-Host -ForegroundColor Green "`nContent to be converted to BBcode:"; Write-Host ($Data | Out-String); } If (($ErrorText) -and (!$Red)) { $Red = $ErrorText } If ($CSVin) { Do { Write-Host "`nWould you like to selectively colour text (" -NoNewline Write-Host "Green" -ForegroundColor Green -NoNewline Write-Host " &/or " -NoNewline Write-Host "Red" -ForegroundColor Red -NoNewline Write-Host ") [Y/N]" $YesNo = Read-Host " " If (($YesNo -ne "Y") -and ($YesNo -ne "N")) { Write-Host "Input Error, enter Y or N." -ForegroundColor Red } } Until (($YesNo -eq "Y") -or ($YesNo -eq "N")) If ($YesNo -eq "y") { $ExitLoop = $false Do { $ExitLoop2 = $false Do { $Green = $Null $Red = $null Write-Host "Enter Text you would like to colour " -NoNewline Write-Host "Green" -ForegroundColor Green -NoNewline Write-Host ",Or press Enter to skip" -NoNewline $Green = Read-Host " " Write-Host "Enter Text you would like to colour " -NoNewline Write-Host "Red" -ForegroundColor Red -NoNewline Write-Host ",Or press Enter to skip" -NoNewline $Red = Read-Host " " Write-Host " " If (($Green.length -ne 0) -and ($Red.length -ne 0)) { If (($Red -like $Green) -or ($Red -like "*$Green*") -or ($Green -like "*$Red*")) { Write-Host "`nError - Values for Green and Red Must be unique and have no overlap.`n" -ForegroundColor Red -NoNewline } Else { $ExitLoop2 = $True } } Else { $ExitLoop2 = $True } } Until ($ExitLoop2) If ($Green.length -ne 0) { Write-Host "Text to colour Green = '" -NoNewline Write-Host "$Green" -ForegroundColor Green -NoNewline Write-Host "'" } If ($Red.length -ne 0) { Write-Host "Text to colour Red = '" -NoNewline Write-Host "$Red" -ForegroundColor Red -NoNewline Write-Host "'" } #Preview the html output of the table. If ($Preview) { IF ($List) { $TempFiles = $TempFiles + (Get-PreviewHTML -Data $Data -Red $Red -Green $Green -List) } Else { $TempFiles = $TempFiles + (Get-PreviewHTML -Data $Data -Red $Red -Green $Green) } } Do { If (($Green.length -ne 0) -or ($Red.length -ne 0)) { Write-Host "Are you happy with the selected colouring [Y/N]" -ForegroundColor Yellow -NoNewline $YesNoColor = Read-Host " " If (($YesNoColor -ne "Y") -and ($YesNoColor -ne "N")) { Write-Host "Input Error, enter Y or N." -ForegroundColor Red } } } Until ((($YesNoColor -eq "Y") -or ($YesNoColor -eq "N")) -or (($Green.length -eq 0) -and ($Red.length -eq 0))) If (($YesNoColor -eq "Y") -or (($Green.length -eq 0) -and ($Red.length -eq 0))) { $ExitLoop = $True } } Until ($ExitLoop) } ElseIf($Preview) { If ($List) { $TempFiles = Get-PreviewHTML -Data $Data -Red $Red -Green $Green -List } Else { $TempFiles = Get-PreviewHTML -Data $Data -Red $Red -Green $Green } } } ElseIf($Preview) { If ($List) { If ($CaseSensitivity) { $TempFiles = Get-PreviewHTML -Data $Data -Red $Red -Green $Green -List -casesensitivity } Else { $TempFiles = Get-PreviewHTML -Data $Data -Red $Red -Green $Green -List } } Else { If ($CaseSensitivity) { $TempFiles = Get-PreviewHTML -Data $Data -Red $Red -Green $Green -casesensitivity } Else { $TempFiles = Get-PreviewHTML -Data $Data -Red $Red -Green $Green } } } # Arrary to store table converted to bbcode. $BBTable = @(); #Converts bbcode to html, then replaces all html table tags with bb code tags e.g.
to [td] If ($List) { $HTML = $Data | ConvertTo-HTML -as list } Else { $HTML = $Data | ConvertTo-HTML } #Add Log entry for AppStats. #Import-Module "$Global:RootPath\Shared_Modules\Logging_Module.psm1" -DisableNameChecking Write-MasterLogFile -functionname "ConvertTo-BBcode" -scriptname "BBCode" -Notes "" -Account "" -Path "$Global:RootPath" #Convert HTML to BBCode. $BBCode = $HTML | foreach {$_ -replace " ",""}` | foreach {$_ -replace "&",""}` | foreach {$_ -replace "","[table]"}` | foreach {$_ -replace "","[/b][/td]"}` | foreach {$_ -replace "","[tr]"}` | foreach {$_ -replace "","[/td]"}` | foreach {$_ -replace "","[/tr]"}` | foreach {$_ -replace "
","[td][b]"}` | foreach {$_ -replace "
","[td]"}` | foreach {$_ -replace "
","[/table]"}` | foreach {$_ -replace "[[]tr[]][[]td[]]
[[]/td[]][[]/tr[]]","[/table]`n`n[table]"}; #A html carrage return is converted to a table break and carrage return $Colour = $Null #Check if Green and Red have values If (($Green.length -ne 0) -and ($Red.length -ne 0)) { #Check if Green and Red values are unique with no overlap. IF ($CaseSensitivity) { If (($Red -clike $Green) -or ($Red -clike "*$Green*") -or ($Green -clike "*$Red*")) { $Colour = $False Write-Host "`n`nError - Values for Green and Red are not unique or overlap, BBCode will NOT be coloured.`n" -ForegroundColor Red -NoNewline } Else { $Colour = $True } } Else { If (($Red -like $Green) -or ($Red -like "*$Green*") -or ($Green -like "*$Red*")) { $Colour = $False Write-Host "`n`nError - Values for Green and Red are not unique or overlap, BBCode will NOT be coloured.`n" -ForegroundColor Red -NoNewline } Else { $Colour = $True } } } Else { $Colour = $True } If ($Colour) { #Colour Green Text If (($Green.length -ne 0) -and (!$CaseSensitivity)) { $BBCode = $BBCode | foreach {If ($_ -like "*$Green*"){$_ -replace "$Green","[color=Green]$Green[/color]"} ELSE {$_}} } ElseIF (($Green) -and ($CaseSensitivity)) { $BBCode = $BBCode | foreach {If ($_ -clike "*$Green*"){$_ -creplace "$Green","[color=Green]$Green[/color]"} ELSE {$_}} } #Colour Red/Error Text If (($Red.length -ne 0) -and (!$CaseSensitivity)) { $BBCode = $BBCode | foreach {If ($_ -like "*$Red*"){$_ -replace "$Red","[color=Red]$Red[/color]"} ELSE {$_}} } ElseIF (($Red) -and ($CaseSensitivity)) { $BBCode = $BBCode | foreach {If ($_ -clike "*$Red*"){$_ -creplace "$Red","[color=Red]$Red[/color]"} ELSE {$_}} } } #Line above strips out the html tags that are left e.g. . Then adds the bbcode table tags to array bbtable. $BBCode | foreach {if ($_ -like "[[]t*") {$BBTable += $_} elseif ($_ -like "[[]/t*") {$BBTable += $_}}; #Stops senario were no code is returned. If ((!$Clip) -and (!$Grid) -and ($NoReturn)) { Write-Host "`nNo option to return output has been selected, defaulting to using clipboard -clip" -ForegroundColor Yellow $Clip = $true } If ($OutputMessage) { If ($Colour) { If ($Red) { Write-Host "Text to colour Red = '" -NoNewline Write-Host "$Red" -ForegroundColor Red -NoNewline Write-Host "'" } If ($Green) { Write-Host "Text to colour Green = '" -NoNewline Write-Host "$Green" -ForegroundColor Green -NoNewline Write-Host "'" } If ($CaseSensativity) { Write-Host -ForegroundColor White "`nCase sensativity for colouring BBCode = Enabled`n`n" } Else { Write-Host -ForegroundColor White "`nCase sensativity for colouring BBCode = Disabled (Default)`n`n" } } If (($Grid) -or ($Clip)) { Write-Host -ForegroundColor Green "`nBBcode Table sent to" -nonewline If ($Grid) { Write-Host -ForegroundColor White " OutGrid," -NoNewline } If ($Clip) { Write-Host -ForegroundColor White " Clipboard." -NoNewline } Write-Host -ForegroundColor Green " paste into core ticket. `nPreview ticket comment before submitting.`n"; } } #Output to screen, outgrid and clipboard. If ($Grid) { #Outgrid is a PowerShell V3 or PowerShell V2 + ISE feacture. #For simplicity I will limit this to PowerShell V3. If ($psver -ge 3) { $BBTable | Out-GridView } Else { Write-Host "`nOutGrid is not avalible, powershell verion 3 or greater required. Device is running Powershell $psver" If (!$Clip) { Write-Host "Sending output to clipboard instead.`n" -ForegroundColor Green $Clip = $true } } } #Output to Clipboard. If ($Clip) {$BBTable | Clip} #Return BBcode table / content of BBTable array. If (!$NoReturn) {return $BBTable} If (($ExitRun -eq $False) -and ($CSVIn)) { Write-Host "Press any key to convert another file..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") #Clear } If ($Preview) { Foreach ($HtmlTmpFile in $TempFiles) { If (Test-Path $HtmlTmpFile) { Remove-Item $HtmlTmpFile } } $HtmlTmpFile = $Null } } Until ($ExitRun) } <# .Synopsis Convert BBCode to HTML. .DESCRIPTION Function to convert BBcode to html. Dones't convert all BBCode option just the most used e.g. 80/20 rule. .EXAMPLE A bbcode table is stored in $BBCode. HTML is outputed to $HTML. $HTML = ConvertTo-BBcodetoHTML -BBCode $BBcode .EXAMPLE BodyTags switch adds html formating at start and end e.g. bbcode $HTML = ConvertTo-BBcodetoHTML -BBCode $BBcode -BodyTags .INPUTS $BBCode - $BBCode input $BodyTags - Add HTML page formating. $Preveiw = Previews the output in HTML. .OUTPUTS $HTML - Array sting containt the HTML conversion of bbcode input .NOTES Function Version = 0.3 Updated = 18/11/2014 Author = Mark Wichall #> Function ConvertTo-BBcodetoHTML { Param ( # Input var containing BBCode data to be converted to HTML. [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$false, Position=0)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] $BBCode, # Switch to add stanard HTML Tags e.g. body, html to begining an end of converted bbcode. [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$false, Position=1)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [Switch] $BodyTags, # Send output to clipboard. [Parameter(ValueFromPipeline=$false, ValueFromPipelineByPropertyName=$false, Position=4)] [Switch] $Clip, # Stop function returing result. [Parameter(ValueFromPipeline=$false, ValueFromPipelineByPropertyName=$false, Position=5)] [Switch] $NoReturn, # Preveiws the output in HTML [Parameter(ValueFromPipeline=$false, ValueFromPipelineByPropertyName=$false, Position=6)] [Switch] $Preview ) $psver = $psversiontable.psversion.major If ($psver -lt 2) { Write-Host "Powershell version $PSver installed. Powershell 2.0 reqiured. Exiting function." -forgroundcolor Red Break } If (!$BBCode) { Write-Host -ForegroundColor Red "Error Data var is empty." Break } # Arrary to store table converted to bbcode. [Array]$HTMLTable = $Null [Array]$HTML = $Null # Converts bbcode to html by replacing all BBcode table tags with html code tags e.g. [td] to
#Convert BBCode to HTML $BBCode | foreach {$_ -replace "[[]table[]]",""} ` | foreach {$_ -replace "[[]td[]][[]b[]]",""} ` | foreach {$_ -replace "[[]tr[]]",""} ` | foreach {$_ -replace "[[]td[]]",""} ` | foreach {$_ -replace "[[]/tr[]]",""} ` | foreach {$_ -replace "[[]/table[]]","
"} ` | foreach {$_ -replace "[[]/b[]][[]/td[]]","
"} ` | foreach {$_ -replace "[[]/td[]]","
"} ` | foreach {$_ -replace "[[]b[]]",""} ` | foreach {$_ -replace "[[]/b[]]",""} ` | foreach {$_ -replace "[[]i[]]",""} ` | foreach {$_ -replace "[[]/i[]]",""} ` | foreach {$_ -replace "[[]s[]]",""} ` | foreach {$_ -replace "[[]/s[]]",""} ` | foreach {$_ -replace "[[]u[]]",""} ` | foreach {$_ -replace "[[]/u[]]",""} ` | foreach {$_ -replace "[[]color=Red[]]",""} ` | foreach {$_ -replace "[[]color=Green[]]",""} ` | foreach {$_ -replace "[[]color=Blue[]]",""} ` | foreach {$_ -replace "[[]color=Yellow[]]",""} ` | foreach {$_ -replace "[[]/color[]]",""} ` | foreach {$HTMLTable += $_} IF ($BodyTags) { $HTMLTop = @" " "@ $HTMLBottom = @" "@ $HTML = $HTMLTop $HTML = $HTML + $HTMLTable $HTML = $HTML + $HTMLBottom } ELSE { $HTML = $HTMLTable } #Import-Module "$Global:RootPath\Shared_Modules\Logging_Module.psm1" -DisableNameChecking Write-MasterLogFile -functionname "ConvertTo-BBcodetoHTML" -scriptname "BBCode" -Notes "" -Account "" -Path "$Global:RootPath" #Output to Clipboard. If ($Clip) {$HTML | Clip} #Preview the html output of the table. If ($Preview) { $tempFile = [io.path]::GetTempFileName() | Rename-Item -NewName { $_ -replace 'tmp$', 'html' } –PassThru $HTML | out-file -filePath $tempFile | Out-Null; Invoke-Command $tempFile #Pasue - Posh 2+ methord Write-Host "Press any key to continue ..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Remove-Item $tempFile } #Return BBcode table / content of BBTable array. If (!$NoReturn) {return $HTML} }