-
-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
804ee02
commit a52fdbf
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
Function Watch-DbaUpdate | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Watches the gallery for updates to dbatools. | ||
.DESCRIPTION | ||
Watches the gallery for updates to dbatools. Only supports Windows 10. | ||
.NOTES | ||
dbatools PowerShell module (https://dbatools.io, [email protected]) | ||
Copyright (C) 2016 Chrissy LeMaire | ||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
.LINK | ||
https://dbatools.io/Watch-DbaUpdate | ||
.EXAMPLE | ||
Watch-DbaUpdate | ||
Watches the gallery for udpates to dbatools. | ||
#> | ||
PROCESS | ||
{ | ||
if (([Environment]::OSVersion).Version.Major -lt 10) | ||
{ | ||
Write-Warning "This command only supports Windows 10 and above" | ||
return | ||
} | ||
|
||
if (!(Get-Module -Name dbatools)) { Import-Module dbatools } | ||
|
||
$null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | ||
$templatetype = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText03 | ||
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($templatetype) | ||
|
||
#Convert to .NET type for XML manipuration | ||
$toastXml = [xml]$template.GetXml() | ||
$null = $toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode("dbatools update")) | ||
|
||
$image = $toastXml.GetElementsByTagName("image") | ||
$image.setAttribute("src", "$PSScriptRoot\bin\thor.png") | ||
$image.setAttribute("alt", "thor") | ||
|
||
#Convert back to WinRT type | ||
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument | ||
$xml.LoadXml($toastXml.OuterXml) | ||
|
||
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml) | ||
$toast.Tag = "PowerShell" | ||
$toast.Group = "PowerShell" | ||
$toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(5) | ||
|
||
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("new version") | ||
$notifier.Show($toast) | ||
|
||
<# | ||
workflow Resume_Workflow | ||
{ | ||
} | ||
# Create the scheduled job properties | ||
$options = New-ScheduledJobOption -ContinueIfGoingOnBattery -StartIfOnBattery | ||
$AtStartup = New-JobTrigger -AtStartup | ||
$scriptblock = { Resume-Job -Name new_resume_workflow_job -Wait } | ||
# Register the scheduled job | ||
Register-ScheduledJob -Name Resume_Workflow_Job -Trigger $AtStartup -ScriptBlock $scriptblock -ScheduledJobOption $options | ||
# Execute the workflow as a new job | ||
Resume_Workflow -AsJob -JobName new_resume_workflow_job | ||
#> | ||
} | ||
} | ||
|
||
Watch-DbaUpdate |