Skip to content

Commit bb99139

Browse files
committed
Add projectUrl at the end of the description in the package selection
Add ProjectUrl if it contains a valid URL to the package selection window
1 parent c63b0f6 commit bb99139

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

install.ps1

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -520,25 +520,31 @@ if (-not $noGui.IsPresent) {
520520
$category = $_.SelectSingleNode("m:properties/d:Tags", $ns).InnerText
521521
# Select only packages that have the latest version, contain a category and the category is not excluded
522522
if (($isLatestVersion -eq "true") -and ($category -ne "") -and ($excludedCategories -notcontains $category)) {
523-
$packageName = $_.properties.Id
524-
$description = $_.properties.Description
525-
526-
# Initialize category as an empty array
527-
if (-not ($packagesByCategory.ContainsKey($category))) {
528-
$packagesByCategory[$category] = @()
529-
}
530-
# Add the PackageName and PackageDesccription to each entry in the array
531-
$packagesByCategory[$category] += [PSCustomObject]@{
532-
PackageName = $packageName
533-
PackageDescription = $description
534-
}
535-
}
536-
}
523+
$packageName = $_.properties.Id
524+
$description = $_.properties.Description
525+
$projectUrl = $_.properties.projectUrl
526+
527+
# Initialize category as an empty array
528+
if (-not ($packagesByCategory.ContainsKey($category))) {
529+
$packagesByCategory[$category] = @()
530+
}
531+
$packageObject = [PSCustomObject]@{
532+
PackageName = $packageName
533+
PackageDescription = $description
534+
}
535+
# Check if $projectUrl contains a valid URL
536+
if ($projectUrl -match "^http") {
537+
Add-Member -InputObject $packageObject -MemberType NoteProperty -Name "PackageUrl" -Value $projectURl
538+
}
539+
# Add the PackageName and PackageDescription (and PackageUrl if present) to each entry in the array
540+
$packagesByCategory[$category] += $packageObject
541+
}
542+
}
537543
# Check if there is a next link in the XML and set the API URL to that link if it exists
538544
$nextLink = $vm_packages.SelectSingleNode("//atom:link[@rel='next']/@href", $ns)
539545
$vmPackagesUrl = $nextLink."#text"
540546

541-
} while ($vmPackagesUrl)
547+
} while ($vmPackagesUrl)
542548

543549
return $packagesByCategory
544550
}
@@ -794,11 +800,6 @@ if (-not $noGui.IsPresent) {
794800
)
795801
return $packagesByCategory[$category]
796802
}
797-
# Function that returns an array of all the packages that are displayed sorted by category from $packagesByCategory
798-
function Get-AllPackages{
799-
$listedPackages = $packagesByCategory.Values | ForEach-Object { $_ } | Select-Object -ExpandProperty PackageName
800-
return $listedPackages
801-
}
802803

803804
# Function that returns additional packages from the config that are not displayed in the textboxes
804805
# which includes both Choco packages and packages from excluded categories
@@ -1003,6 +1004,20 @@ if (-not $noGui.IsPresent) {
10031004
$checkBox.Name = "checkBox$numCheckBoxPackages"
10041005
$checkboxesPackages.Add($checkBox)
10051006
$panelCategories.Controls.Add($checkBox)
1007+
$url = $package.PackageUrl
1008+
if ($url){
1009+
$linkProjectUrl = New-Object System.Windows.Forms.linkLabel
1010+
$linkProjectUrl.Top = $checkbox.Top + 2
1011+
$linkProjectUrl.Left = $checkbox.Right - 3
1012+
$linkProjectUrl.AutoSize = $true
1013+
$linkProjectUrl.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
1014+
$linkProjectUrl.LinkColor = "BLUE";
1015+
$linkProjectUrl.ActiveLinkColor = "RED"
1016+
$linkProjectUrl.Text = "Link"
1017+
$linkProjectUrl.Links.Add(0, 4, $url)| Out-Null
1018+
$linkProjectUrl.add_Click({ Start-Process $this.Links.LinkData })
1019+
$panelCategories.Controls.Add($linkProjectUrl)
1020+
}
10061021
$verticalPosition2 += 20
10071022
$numCheckBoxPackages ++
10081023
}
@@ -1069,7 +1084,7 @@ if (-not $noGui.IsPresent) {
10691084
$linkLabelChoco.LinkColor = "BLUE"
10701085
$linkLabelChoco.ActiveLinkColor = "RED"
10711086
$linkLabelChoco.Text = "https://community.chocolatey.org/packages"
1072-
$linkLabelChoco.add_Click({[system.Diagnostics.Process]::start("https://community.chocolatey.org/packages")})
1087+
$linkLabelChoco.add_Click({Start-Process "https://community.chocolatey.org/packages"})
10731088

10741089
$labelFlarevm = New-Object System.Windows.Forms.Label
10751090
$labelFlarevm.Location = New-Object System.Drawing.Point(300,680)
@@ -1085,7 +1100,7 @@ if (-not $noGui.IsPresent) {
10851100
$linkLabelFlarevm.LinkColor = "BLUE"
10861101
$linkLabelFlarevm.ActiveLinkColor = "RED"
10871102
$linkLabelFlarevm.Text = "https://github.com/mandiant/VM-Packages/wiki/Packages"
1088-
$linkLabelFlarevm.add_Click({[system.Diagnostics.Process]::start("https://github.com/mandiant/VM-Packages/wiki/Packages")})
1103+
$linkLabelFlarevm.add_Click({Start-Process "https://github.com/mandiant/VM-Packages/wiki/Packages"})
10891104

10901105
Set-AdditionalPackages
10911106

0 commit comments

Comments
 (0)