From fc083ceaba22adb1f4cb52a85de2d0a116b01174 Mon Sep 17 00:00:00 2001 From: Martin Bengtsson Date: Fri, 3 Jul 2020 21:29:26 +0200 Subject: [PATCH] Add files via upload --- Custom Protocols/Run-ApplicationID.ps1 | 54 +++++++++++++++++++++ Custom Protocols/Run-PackageID.ps1 | 20 ++++++++ Custom Protocols/ToastReboot.cmd | 1 + Custom Protocols/ToastRebootProtocol.reg | Bin 0 -> 658 bytes Custom Protocols/ToastRunApplicationID.cmd | 2 + Custom Protocols/ToastRunApplicationID.reg | 12 +++++ Custom Protocols/ToastRunPackageID.cmd | 2 + Custom Protocols/ToastRunPackageID.reg | Bin 0 -> 730 bytes 8 files changed, 91 insertions(+) create mode 100644 Custom Protocols/Run-ApplicationID.ps1 create mode 100644 Custom Protocols/Run-PackageID.ps1 create mode 100644 Custom Protocols/ToastReboot.cmd create mode 100644 Custom Protocols/ToastRebootProtocol.reg create mode 100644 Custom Protocols/ToastRunApplicationID.cmd create mode 100644 Custom Protocols/ToastRunApplicationID.reg create mode 100644 Custom Protocols/ToastRunPackageID.cmd create mode 100644 Custom Protocols/ToastRunPackageID.reg diff --git a/Custom Protocols/Run-ApplicationID.ps1 b/Custom Protocols/Run-ApplicationID.ps1 new file mode 100644 index 0000000..0203a7c --- /dev/null +++ b/Custom Protocols/Run-ApplicationID.ps1 @@ -0,0 +1,54 @@ +<# +.SYNOPSIS + Script used to execute applications directly from my Windows 10 Toast Notification Script + +.NOTES + Filename: Run-ApplicationID.ps1 + Version: 1.0 + Author: Martin Bengtsson + Blog: www.imab.dk + Twitter: @mwbengtsson + +.LINKS + https://www.imab.dk/windows-10-toast-notification-script +#> + +# Function for triggering the installation or reparing of applications +# Parts of this function is heavily inspired by Timmy's post at: https://timmyit.com/2016/08/08/sccm-and-powershell-force-installuninstall-of-available-software-in-software-center-through-cimwmi-on-a-remote-client/ +# Function is modified to cater for a scenario where the application needs repairing instead of installing +# Also removed bits and pieces which I don't need :-) +function Trigger-AppInstallation() { + param( + [String][Parameter(Mandatory=$true)] $appID + ) + + Begin { + $application = (Get-CimInstance -ClassName CCM_Application -Namespace "root\ccm\clientSDK" | Where-Object {$_.Id -eq $appID}) + $args = @{EnforcePreference = [UINT32] 0 + Id = "$($application.Id)" + IsMachineTarget = $application.IsMachineTarget + IsRebootIfNeeded = $false + Priority = 'High' + Revision = "$($application.Revision)"} + } + + Process { + if ($application.InstallState -eq "NotInstalled") { + try { + Invoke-CimMethod -Namespace "root\ccm\clientSDK" -ClassName CCM_Application -MethodName Install -Arguments $args + } + catch { } + } + elseif ($application.InstallState -eq "Installed") { + try { + Invoke-CimMethod -Namespace "root\ccm\clientSDK" -ClassName CCM_Application -MethodName Repair -Arguments $args + } + catch { } + } + } + + End { } +} +$registryPath = "HKCU:\SOFTWARE\ToastNotificationScript" +$applicationID = (Get-ItemProperty -Path $RegistryPath -Name "RunApplicationID").RunApplicationID +Trigger-AppInstallation -appID $applicationID \ No newline at end of file diff --git a/Custom Protocols/Run-PackageID.ps1 b/Custom Protocols/Run-PackageID.ps1 new file mode 100644 index 0000000..a3fe297 --- /dev/null +++ b/Custom Protocols/Run-PackageID.ps1 @@ -0,0 +1,20 @@ +<# +.SYNOPSIS + Script used to execute packages and task sequences directly from my Windows 10 Toast Notification Script + +.NOTES + Filename: Run-PackageID.ps1 + Version: 1.0 + Author: Martin Bengtsson + Blog: www.imab.dk + Twitter: @mwbengtsson + +.LINKS + https://www.imab.dk/windows-10-toast-notification-script +#> + +$RegistryPath = "HKCU:\SOFTWARE\ToastNotificationScript" +$PackageID = (Get-ItemProperty -Path $RegistryPath -Name "RunPackageID").RunPackageID +$SoftwareCenter = New-Object -ComObject "UIResource.UIResourceMgr" +$ProgramID = "*" +$SoftwareCenter.ExecuteProgram($ProgramID,$PackageID,$true) \ No newline at end of file diff --git a/Custom Protocols/ToastReboot.cmd b/Custom Protocols/ToastReboot.cmd new file mode 100644 index 0000000..27f3f82 --- /dev/null +++ b/Custom Protocols/ToastReboot.cmd @@ -0,0 +1 @@ +shutdown /r /t 0 /d p:0:0 /c "Toast Notification Reboot" \ No newline at end of file diff --git a/Custom Protocols/ToastRebootProtocol.reg b/Custom Protocols/ToastRebootProtocol.reg new file mode 100644 index 0000000000000000000000000000000000000000..190bda078d0948b9b714e07e6145370bb29b8547 GIT binary patch literal 658 zcmcJN-AV&N428dI!FO1EfZ~lef}qrbU{SIDAdZw;wJvmb%C;cBeCs!}NGs@-O2|Tz zb563!td_Tw)I1S+V@|;(&rHnCS