From dbce494fc1e876eb871ff78b98dbd579a5fd33c9 Mon Sep 17 00:00:00 2001 From: Martin Bengtsson Date: Sat, 22 Aug 2020 20:40:26 +0200 Subject: [PATCH] Delete Run-ApplicationID.ps1 --- Custom Protocols/Run-ApplicationID.ps1 | 54 -------------------------- 1 file changed, 54 deletions(-) delete mode 100644 Custom Protocols/Run-ApplicationID.ps1 diff --git a/Custom Protocols/Run-ApplicationID.ps1 b/Custom Protocols/Run-ApplicationID.ps1 deleted file mode 100644 index 0203a7c..0000000 --- a/Custom Protocols/Run-ApplicationID.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -<# -.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