I am looking to improve the layout and sorting options of my datagridview table. The code, shared below, is working and it is presenting the information correctly. However, my limited powershell skills does not help me on making some improvements such as adding sorting option for the first “date-time” column, add color to the rows based on the alert message (information (white), degradation, disruption (red)), and adding an option to shrink or expand the rows. Please, Please, if you have a suggestion on to improve the code and the goal is still achieved, please teach me with an example what to change.Thanks!
$outputBox040 = Invoke-WebRequest -Uri ‘https://*.rss’ -OutFile C:*.rss
[xml]$Content = Get-Content C:*.rss
$Feed = $Content.rss.channel
$url = foreach ($msg in $Feed.item){
$commentsPlain = $msg.description.InnerText -replace ‘<br ?/?>’,[System.Environment]::NewLine -replace ‘<[^>]+>’
[PSCustomObject]@{
‘Date-Time’ = [datetime]$msg.pubDate
‘Title’ = “$($msg.title), ,
$($commentsPlain)”
#‘Link’ = $msg.link.InnerText
#‘Comments’ = $commentsPlain
‘Category’ = $msg.category
}
}
$list = New-Object System.collections.ArrayList
$list.AddRange(@($url))
$outputbox040 = New-Object System.Windows.Forms.DataGridView -Property @{
Size=New-Object System.Drawing.Size(718,505)
Location = New-Object System.Drawing.Size(0,1)
ColumnHeadersVisible = $true
AutoSizeColumnsMode = ‘DisplayedCellsExceptHeader’
AutoSizeRowsMode = ‘AllCells’
AllowUserToDeleteRows = ‘false’
DefaultCellStyle= @{WrapMode =‘True’}
RowHeadersVisible = $false
ReadOnly = ‘true’
DataSource = $list
}
$AlertsPage.Controls.Add($outputBox040)