Created
November 6, 2020 01:09
-
-
Save steviecoaster/aa55335b559ec126b6c677abef65b6fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$outdated = choco outdated -r | ConvertFrom-Csv -Delimiter '|' -Header 'PackageName', 'CurrentVersion', 'LatestVersion', 'Pinned' | |
$outdated = $outdated | Select-Object PackageName, CurrentVersion, LatestVersion, @{Name = 'Outdated'; Expression = { if ([version]$_.LatestVersion -gt [version]$_.CurrentVersion) { $true } else { $false } } } | |
$outdatedpackages = $outdated | Where-Object { $_.Outdated -eq $true } | Select-Object -First 4 | |
$packageCollection = @() | |
$x = 24020 | |
foreach ($odp in $outdatedpackages) { | |
#$packageCollection.Add($($odp.Packagename)) | |
$item = [pscustomobject]@{ | |
id = $x | |
package = New-BTSelectionBoxItem -Id "$([string]$x)" -Content $odp.PackageName | |
} | |
$packageCollection += $item | |
$x ++ | |
} | |
$all = [pscustomobject]@{ | |
id = 'all' | |
package = New-BTSelectionBoxItem -Id 'All' -Content 'All' | |
} | |
$packageCollection += $all | |
$Text1 = New-BTText -Content 'Choco Package Upgrades Available' | |
$ImagePath = "C:\ProgramData\BurntToast\choco.ico" | |
$Image1 = New-BTImage -Source $ImagePath -AppLogoOverride -Crop None | |
$Audio1 = New-BTAudio -Source 'ms-winsoundevent:Notification.Default' | |
$Binding1 = New-BTBinding -Children $Text1 -AppLogoOverride $Image1 | |
$Visual1 = New-BTVisual -BindingGeneric $Binding1 | |
$BTInput = New-BTInput -Id 'Selection001' -Title 'Select package to upgrade' -DefaultSelectionBoxItemId '24020' -Items $packageCollection.package | |
$Submit = New-BTButton -Content 'Submit' -Arguments "powershell://C:\ProgramData\BurntToast\choco.ps1" -ActivationType Protocol | |
$Dismiss = New-BTButton -Dismiss | |
$Actions = New-BTAction -Inputs $BTInput -Buttons $Submit, $Dismiss | |
$Content1 = New-BTContent -Visual $Visual1 -Audio $Audio1 -Actions $Actions | |
$Activated = { | |
<# | |
if ($Event.SourceArgs[1].Arguments -ne 'dismiss') { | |
switch ($Event.SourceArgs[1].UserInput.value) { | |
'24020' { | |
$ToastPackage = (($packageCollection | ? $_.id -eq '24020').package.content) | |
} | |
'24021' { | |
$ToastPackage = (($packageCollection | ? $_.id -eq '24021').package.content) | |
} | |
'24022' { | |
$ToastPackage = (($packageCollection | ? $_.id -eq '24022').package.content) | |
} | |
'24023' { | |
$ToastPackage = (($packageCollection | ? $_.id -eq '24023').package.content) | |
} | |
'all' { | |
$ToastPackage = (($packageCollection | ? $_.id -eq '24024').package.content) | |
} | |
} | |
} | |
#> | |
$event.SourceArgs[1] > C:\tmp\selection.txt | |
#$chocoArgs = @('install', "$ToastPackage", '-y','--log-file C:\tmp\chocolatey.toast.log') | |
#choco install $ToastPackage -y --log-file C:\tmp\chocolatey.toast.log | |
} | |
Submit-BTNotification -Content $Content1 -ActivatedAction $Activated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment