Merge 07d3a83d36 into 4b6d3b8c5b
This commit is contained in:
commit
7482111111
2 changed files with 155 additions and 121 deletions
|
|
@ -82,18 +82,18 @@
|
||||||
** As well as added support for dynamic deadline retrieval for software updates **
|
** As well as added support for dynamic deadline retrieval for software updates **
|
||||||
** Stuff has been rewritten to suit my understanding and thoughts of the script **
|
** Stuff has been rewritten to suit my understanding and thoughts of the script **
|
||||||
|
|
||||||
2.0.0 - Huge changes to how this script handles custom protocols
|
2.0.0 - Huge changes to how this script handles custom protocols
|
||||||
Added Support for Custom Actions/Protocols within the script under user context removing the need for that to be run under SYSTEM/ADMIN
|
Added Support for Custom Actions/Protocols within the script under user context removing the need for that to be run under SYSTEM/ADMIN
|
||||||
- <Option Name="Action" Value="ToastRunUpdateID:" />
|
- <Option Name="Action" Value="ToastRunUpdateID:" />
|
||||||
- <Option Name="Action" Value="ToastRunPackageID:" />
|
- <Option Name="Action" Value="ToastRunPackageID:" />
|
||||||
- <Option Name="Action" Value="ToastRunApplicationID:" />
|
- <Option Name="Action" Value="ToastRunApplicationID:" />
|
||||||
- <Option Name="Action" Value="ToastReboot:" />
|
- <Option Name="Action" Value="ToastReboot:" />
|
||||||
Added Support to dynamically create Custom Action Scripts to support Custom Protocols
|
Added Support to dynamically create Custom Action Scripts to support Custom Protocols
|
||||||
Added Support for Software (Feature) Updates : Searches for an update and will store in variable
|
Added Support for Software (Feature) Updates : Searches for an update and will store in variable
|
||||||
Added new XML Types for Software Updates:
|
Added new XML Types for Software Updates:
|
||||||
- <Option Name="RunUpdateID" Enabled="True" Value="3012973" />
|
- <Option Name="RunUpdateID" Enabled="True" Value="3012973" />
|
||||||
- <Option Name="RunUpdateTitle" Enabled="True" Value="Version 1909" />
|
- <Option Name="RunUpdateTitle" Enabled="True" Value="Version 1909" />
|
||||||
Added support for getting deadline date/time dynamically for software updates
|
Added support for getting deadline date/time dynamically for software updates
|
||||||
- Configure DynamicDeadline with the UpdateID
|
- Configure DynamicDeadline with the UpdateID
|
||||||
|
|
||||||
2.0.1 - Updated custom action scripts!
|
2.0.1 - Updated custom action scripts!
|
||||||
|
|
@ -106,7 +106,7 @@
|
||||||
- If newer version is available from the script, new custom action scripts will be created
|
- If newer version is available from the script, new custom action scripts will be created
|
||||||
- This allows me to make sure the relevant scripts are in place in case I change something along the way
|
- This allows me to make sure the relevant scripts are in place in case I change something along the way
|
||||||
- Modified script output of custom script for RunPackageID to pick up Program ID dynamically
|
- Modified script output of custom script for RunPackageID to pick up Program ID dynamically
|
||||||
Added support for getting deadline date/time dynamically for applications
|
Added support for getting deadline date/time dynamically for applications
|
||||||
- Configure DynamicDeadline with the Application ID
|
- Configure DynamicDeadline with the Application ID
|
||||||
|
|
||||||
2.0.2 - Fixed an error in the custom protocols
|
2.0.2 - Fixed an error in the custom protocols
|
||||||
|
|
@ -267,21 +267,21 @@ function Get-GivenName() {
|
||||||
if (Get-Service -Name ccmexec -ErrorAction SilentlyContinue) {
|
if (Get-Service -Name ccmexec -ErrorAction SilentlyContinue) {
|
||||||
Write-Log -Message "Looking for logged on user's SID in WMI with CCM client"
|
Write-Log -Message "Looking for logged on user's SID in WMI with CCM client"
|
||||||
$LoggedOnSID = Get-CimInstance -Namespace ROOT\CCM -Class CCM_UserLogonEvents -Filter "LogoffTime=null" | Select -ExpandProperty UserSID
|
$LoggedOnSID = Get-CimInstance -Namespace ROOT\CCM -Class CCM_UserLogonEvents -Filter "LogoffTime=null" | Select -ExpandProperty UserSID
|
||||||
if ($LoggedOnSID.GetType().IsArray) {
|
if ($LoggedOnSID.GetType().IsArray) {
|
||||||
Write-Log -Message "Multiple SID's found logged on. Skipping"
|
Write-Log -Message "Multiple SID's found logged on. Skipping"
|
||||||
$GivenName = $null
|
$GivenName = $null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$RegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData"
|
$RegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData"
|
||||||
$DisplayName = (Get-ChildItem -Path $RegKey | Where-Object {$_.GetValue("LoggedOnUserSID") -eq $LoggedOnSID} | Select-Object -First 1).GetValue("LoggedOnDisplayName")
|
$DisplayName = (Get-ChildItem -Path $RegKey | Where-Object {$_.GetValue("LoggedOnUserSID") -eq $LoggedOnSID} | Select-Object -First 1).GetValue("LoggedOnDisplayName")
|
||||||
if ($DisplayName) {
|
if ($DisplayName) {
|
||||||
$GivenName = $DisplayName.Split()[0].Trim()
|
$GivenName = $DisplayName.Split()[0].Trim()
|
||||||
Write-Log -Message "Given name found matching logged on user SID: $GivenName"
|
Write-Log -Message "Given name found matching logged on user SID: $GivenName"
|
||||||
$GivenName
|
$GivenName
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GivenName = $null
|
$GivenName = $null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -788,7 +788,13 @@ function Write-CustomActionRegistry() {
|
||||||
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
$RegCommandValue = $RegCommandPath + '\' + "$($ActionType).cmd"
|
# to be able to run vbs from Toast Notification (https://www.windows10forums.com/threads/custom-protocol-handler-does-not-work-in-ms-edge-in-win10.14698/)
|
||||||
|
# 0x210000 is join of these values:
|
||||||
|
# FTA_OpenIsSafe - 0x00010000
|
||||||
|
# FTA_SafeForElevation - 0x00200000
|
||||||
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb762506(v=vs.85).aspx
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'EditFlags' -Value '0x210000' -PropertyType Dword -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
$RegCommandValue = "wscript.exe $RegCommandPath\ToastRunScriptWithoutGUI.vbs" + " " + $RegCommandPath + '\' + "$($ActionType).cmd"
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
@ -803,7 +809,13 @@ function Write-CustomActionRegistry() {
|
||||||
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
$RegCommandValue = $RegCommandPath + '\' + "$($ActionType).cmd"
|
# to be able to run vbs from Toast Notification (https://www.windows10forums.com/threads/custom-protocol-handler-does-not-work-in-ms-edge-in-win10.14698/)
|
||||||
|
# 0x210000 is join of these values:
|
||||||
|
# FTA_OpenIsSafe - 0x00010000
|
||||||
|
# FTA_SafeForElevation - 0x00200000
|
||||||
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb762506(v=vs.85).aspx
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'EditFlags' -Value '0x210000' -PropertyType Dword -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
$RegCommandValue = "wscript.exe $RegCommandPath\ToastRunScriptWithoutGUI.vbs" + " " + $RegCommandPath + '\' + "$($ActionType).ps1"
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
@ -818,7 +830,13 @@ function Write-CustomActionRegistry() {
|
||||||
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
$RegCommandValue = $RegCommandPath + '\' + "$($ActionType).cmd"
|
# to be able to run vbs from Toast Notification (https://www.windows10forums.com/threads/custom-protocol-handler-does-not-work-in-ms-edge-in-win10.14698/)
|
||||||
|
# 0x210000 is join of these values:
|
||||||
|
# FTA_OpenIsSafe - 0x00010000
|
||||||
|
# FTA_SafeForElevation - 0x00200000
|
||||||
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb762506(v=vs.85).aspx
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'EditFlags' -Value '0x210000' -PropertyType Dword -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
$RegCommandValue = "wscript.exe $RegCommandPath\ToastRunScriptWithoutGUI.vbs" + " " + $RegCommandPath + '\' + "$($ActionType).ps1"
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
@ -833,7 +851,13 @@ function Write-CustomActionRegistry() {
|
||||||
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
$RegCommandValue = $RegCommandPath + '\' + "$($ActionType).cmd"
|
# to be able to run vbs from Toast Notification (https://www.windows10forums.com/threads/custom-protocol-handler-does-not-work-in-ms-edge-in-win10.14698/)
|
||||||
|
# 0x210000 is join of these values:
|
||||||
|
# FTA_OpenIsSafe - 0x00010000
|
||||||
|
# FTA_SafeForElevation - 0x00200000
|
||||||
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb762506(v=vs.85).aspx
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'EditFlags' -Value '0x210000' -PropertyType Dword -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
$RegCommandValue = "wscript.exe $RegCommandPath\ToastRunScriptWithoutGUI.vbs" + " " + $RegCommandPath + '\' + "$($ActionType).ps1"
|
||||||
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
@ -842,6 +866,27 @@ function Write-CustomActionRegistry() {
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#FIXME ToastRunPSBase64 I added in different branch, so just for you to know how to set its RegCommandValue
|
||||||
|
ToastRunPSBase64 {
|
||||||
|
# Build out registry for custom action for running PowerShell command encoded as Base64 via the action button
|
||||||
|
try {
|
||||||
|
New-Item "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'URL Protocol' -Value '' -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name '(default)' -Value "URL:$($ActionType) Protocol" -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
# to be able to run vbs from Toast Notification (https://www.windows10forums.com/threads/custom-protocol-handler-does-not-work-in-ms-edge-in-win10.14698/)
|
||||||
|
# 0x210000 is join of these values:
|
||||||
|
# FTA_OpenIsSafe - 0x00010000
|
||||||
|
# FTA_SafeForElevation - 0x00200000
|
||||||
|
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb762506(v=vs.85).aspx
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)" -Name 'EditFlags' -Value '0x210000' -PropertyType Dword -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
$RegCommandValue = "wscript.exe $RegCommandPath\ToastRunScriptWithoutGUI.vbs" + " " + "`"%1`"" # %1 in quotes because it contains equal sign, which will be otherwise removed
|
||||||
|
New-ItemProperty -LiteralPath "HKCU:\Software\Classes\$($ActionType)\shell\open\command" -Name '(default)' -Value $RegCommandValue -PropertyType String -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
} catch {
|
||||||
|
Write-Log -Level Error "Failed to create the $ActionType custom protocol in HKCU\Software\Classes. Action button might not work"
|
||||||
|
$ErrorMessage = $_.Exception.Message
|
||||||
|
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -853,7 +898,7 @@ function Write-CustomActionScript() {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[Parameter(Position="0")]
|
[Parameter(Position="0")]
|
||||||
[ValidateSet("ToastRunApplicationID","ToastRunPackageID","ToastRunUpdateID","ToastReboot")]
|
[ValidateSet("ToastRunApplicationID", "ToastRunPackageID", "ToastRunUpdateID", "ToastReboot", "ToastRunScriptWithoutGUI")]
|
||||||
[string] $Type,
|
[string] $Type,
|
||||||
[Parameter(Position="1")]
|
[Parameter(Position="1")]
|
||||||
[String] $Path = $global:CustomScriptsPath
|
[String] $Path = $global:CustomScriptsPath
|
||||||
|
|
@ -862,34 +907,6 @@ function Write-CustomActionScript() {
|
||||||
switch ($Type) {
|
switch ($Type) {
|
||||||
# Create custom scripts for running software updates via the action button
|
# Create custom scripts for running software updates via the action button
|
||||||
ToastRunUpdateID {
|
ToastRunUpdateID {
|
||||||
try {
|
|
||||||
$CMDFileName = $Type + '.cmd'
|
|
||||||
$CMDFilePath = $Path + '\' + $CMDFileName
|
|
||||||
try {
|
|
||||||
New-item -Path $Path -Name $CMDFileName -Force -OutVariable PathInfo | Out-Null
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$GetCustomScriptPath = $PathInfo.FullName
|
|
||||||
[String]$Script = "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File `"$global:CustomScriptsPath\ToastRunUpdateID.ps1`""
|
|
||||||
if (-NOT[string]::IsNullOrEmpty($Script)) {
|
|
||||||
Out-File -FilePath $GetCustomScriptPath -InputObject $Script -Encoding ASCII -Force
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
$PS1FileName = $Type + '.ps1'
|
$PS1FileName = $Type + '.ps1'
|
||||||
$PS1FilePath = $Path + '\' + $PS1FileName
|
$PS1FilePath = $Path + '\' + $PS1FileName
|
||||||
|
|
@ -967,34 +984,6 @@ exit 0
|
||||||
# Previously this was hard coded to '*', making it work for task sequences only. Now also works for regular packages (only one program).
|
# Previously this was hard coded to '*', making it work for task sequences only. Now also works for regular packages (only one program).
|
||||||
# Create custom scripts to run packages and task sequences directly from the action button
|
# Create custom scripts to run packages and task sequences directly from the action button
|
||||||
ToastRunPackageID {
|
ToastRunPackageID {
|
||||||
try {
|
|
||||||
$CMDFileName = $Type + '.cmd'
|
|
||||||
$CMDFilePath = $Path + '\' + $CMDFileName
|
|
||||||
try {
|
|
||||||
New-item -Path $Path -Name $CMDFileName -Force -OutVariable PathInfo | Out-Null
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$GetCustomScriptPath = $PathInfo.FullName
|
|
||||||
[String]$Script = "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File `"$global:CustomScriptsPath\ToastRunPackageID.ps1`""
|
|
||||||
if (-NOT[string]::IsNullOrEmpty($Script)) {
|
|
||||||
Out-File -FilePath $GetCustomScriptPath -InputObject $Script -Encoding ASCII -Force
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
$PS1FileName = $Type + '.ps1'
|
$PS1FileName = $Type + '.ps1'
|
||||||
$PS1FilePath = $Path + '\' + $PS1FileName
|
$PS1FilePath = $Path + '\' + $PS1FileName
|
||||||
|
|
@ -1038,35 +1027,6 @@ exit 0
|
||||||
}
|
}
|
||||||
# Create custom scripts to run applications directly from the action button
|
# Create custom scripts to run applications directly from the action button
|
||||||
ToastRunApplicationID {
|
ToastRunApplicationID {
|
||||||
try {
|
|
||||||
$CMDFileName = $Type + '.cmd'
|
|
||||||
$CMDFilePath = $Path + '\' + $CMDFileName
|
|
||||||
try {
|
|
||||||
New-item -Path $Path -Name $CMDFileName -Force -OutVariable PathInfo | Out-Null
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$GetCustomScriptPath = $PathInfo.FullName
|
|
||||||
[String]$Script = "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File `"$global:CustomScriptsPath\ToastRunApplicationID.ps1`""
|
|
||||||
if (-NOT[string]::IsNullOrEmpty($Script)) {
|
|
||||||
Out-File -FilePath $GetCustomScriptPath -InputObject $Script -Encoding ASCII -Force
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
|
||||||
$ErrorMessage = $_.Exception.Message
|
|
||||||
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
$PS1FileName = $Type + '.ps1'
|
$PS1FileName = $Type + '.ps1'
|
||||||
$PS1FilePath = $Path + '\' + $PS1FileName
|
$PS1FilePath = $Path + '\' + $PS1FileName
|
||||||
|
|
@ -1113,13 +1073,87 @@ exit 0
|
||||||
# Do not run another type; break
|
# Do not run another type; break
|
||||||
Break
|
Break
|
||||||
}
|
}
|
||||||
|
ToastRunScriptWithoutGUI {
|
||||||
|
try {
|
||||||
|
$VBSFileName = 'ToastRunScriptWithoutGUI.vbs'
|
||||||
|
try {
|
||||||
|
New-Item -Path $Path -Name $VBSFileName -Force -OutVariable PathInfo | Out-Null
|
||||||
|
} catch {
|
||||||
|
$ErrorMessage = $_.Exception.Message
|
||||||
|
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$GetCustomScriptPath = $PathInfo.FullName
|
||||||
|
[String]$Script = @'
|
||||||
|
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||||
|
|
||||||
|
' regex to distinguish ps1 scripts
|
||||||
|
Set runPs1 = New RegExp
|
||||||
|
With runPs1
|
||||||
|
.Pattern = "\.ps1$"
|
||||||
|
.IgnoreCase = True
|
||||||
|
.Global = False
|
||||||
|
End With
|
||||||
|
' regex to distinguish base64
|
||||||
|
Set runBase64 = New RegExp
|
||||||
|
With runBase64
|
||||||
|
.Pattern = "^toastrunpsbase64:"
|
||||||
|
.IgnoreCase = True
|
||||||
|
.Global = False
|
||||||
|
End With
|
||||||
|
|
||||||
|
If Wscript.Arguments.Count < 1 Or Wscript.Arguments.Count > 2 Then
|
||||||
|
wscript.echo "ERROR, you have to enter one or two argument(s)! First has to be the path to cmd file to run and voluntarily second one as CMDs file argument"
|
||||||
|
ElseIf Wscript.Arguments.Count = 1 Then
|
||||||
|
If runPs1.Test( WScript.Arguments(0) ) Then
|
||||||
|
' it is ps1 script
|
||||||
|
WshShell.Run "cmd /c powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File" & " " & """" & WScript.Arguments(0) & """", 0, True
|
||||||
|
ElseIf runBase64.Test( WScript.Arguments(0) ) Then
|
||||||
|
' it is base64 string
|
||||||
|
'remove part before : from passed string to get just base64
|
||||||
|
base64 = WScript.Arguments(0)
|
||||||
|
base64 = Mid(base64,instr(base64,":")+1)
|
||||||
|
WshShell.Run "cmd /c powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -EncodedCommand" & " " & """" & base64 & """", 0, True
|
||||||
|
Else
|
||||||
|
' it is something else
|
||||||
|
WshShell.Run """" & WScript.Arguments(0) & """", 0, True
|
||||||
|
End If
|
||||||
|
ElseIf Wscript.Arguments.Count = 2 Then
|
||||||
|
'wscript.echo WScript.Arguments(0)
|
||||||
|
'wscript.echo WScript.Arguments(1)
|
||||||
|
If runPs1.Test( WScript.Arguments(0) ) Then
|
||||||
|
' it is ps1 script
|
||||||
|
WshShell.Run "cmd /c powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File" & " " & """" & WScript.Arguments(0) & """" & " " & """" & WScript.Arguments(1) & """", 0, True
|
||||||
|
Else
|
||||||
|
' it isn't ps1 script
|
||||||
|
WshShell.Run """" & WScript.Arguments(0) & """" & """" & WScript.Arguments(1) & """", 0, True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
Set WshShell = Nothing
|
||||||
|
'@
|
||||||
|
if (-NOT[string]::IsNullOrEmpty($Script)) {
|
||||||
|
Out-File -FilePath $GetCustomScriptPath -InputObject $Script -Encoding ASCII -Force
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
||||||
|
$ErrorMessage = $_.Exception.Message
|
||||||
|
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Log -Level Error "Failed to create the custom .cmd script for $Type. Action button might not work"
|
||||||
|
$ErrorMessage = $_.Exception.Message
|
||||||
|
Write-Log -Level Error -Message "Error message: $ErrorMessage"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
######### GENERAL VARIABLES #########
|
######### GENERAL VARIABLES #########
|
||||||
# Global variables
|
# Global variables
|
||||||
# Setting global script version
|
# Setting global script version
|
||||||
$global:ScriptVersion = "2.1.0"
|
$global:ScriptVersion = "2.1.6"
|
||||||
# Setting executing directory
|
# Setting executing directory
|
||||||
$global:ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
$global:ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||||
# Setting global custom action script location
|
# Setting global custom action script location
|
||||||
|
|
@ -1629,6 +1663,7 @@ if ($CreateScriptsProtocolsEnabled -eq "True") {
|
||||||
Write-CustomActionScript -Type ToastRunApplicationID
|
Write-CustomActionScript -Type ToastRunApplicationID
|
||||||
Write-CustomActionScript -Type ToastRunPackageID
|
Write-CustomActionScript -Type ToastRunPackageID
|
||||||
Write-CustomActionScript -Type ToastRunUpdateID
|
Write-CustomActionScript -Type ToastRunUpdateID
|
||||||
|
Write-CustomActionScript -Type ToastRunScriptWithoutGUI
|
||||||
New-ItemProperty -Path $global:RegistryPath -Name $RegistryName -Value $global:ScriptVersion -PropertyType "String" -Force | Out-Null
|
New-ItemProperty -Path $global:RegistryPath -Name $RegistryName -Value $global:ScriptVersion -PropertyType "String" -Force | Out-Null
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
<Option Name="ADPasswordExpirationText" Enabled="False" /> <!-- Adds an additional group to the toast with text -->
|
<Option Name="ADPasswordExpirationText" Enabled="False" /> <!-- Adds an additional group to the toast with text -->
|
||||||
<Option Name="ADPasswordExpirationDays" Value="90" /> <!-- How many days in advance shall the toast start reminding the users -->
|
<Option Name="ADPasswordExpirationDays" Value="90" /> <!-- How many days in advance shall the toast start reminding the users -->
|
||||||
<Option Name="RunPackageID" Enabled="False" Value="KR100907" /> <!-- Will enable the toast to run any ConfigMgr PackageID through a custom protocol -->
|
<Option Name="RunPackageID" Enabled="False" Value="KR100907" /> <!-- Will enable the toast to run any ConfigMgr PackageID through a custom protocol -->
|
||||||
<Option Name="RunApplicationID" Enabled="False" Value="ScopeId_A9117680-D054-482B-BC97-532E6CBD0E6B/Application_fd55f35c-4e34-4490-a3ec-ee0b79233ec6" /> <!-- Will enable the toast to run any ConfigMgr ApplicationID through a custom protocol -->
|
|
||||||
<Option Name="RunUpdateID" Enabled="False" Value="4561600" /> <!-- Will enable the toast to run any ConfigMgr Update ID through a custom protocol. Configure the value to the relevant KB-article ID -->
|
<Option Name="RunUpdateID" Enabled="False" Value="4561600" /> <!-- Will enable the toast to run any ConfigMgr Update ID through a custom protocol. Configure the value to the relevant KB-article ID -->
|
||||||
<Option Name="RunUpdateTitle" Enabled="False" Value="" /> <!-- Will enable the toast to run any ConfigMgr Update Name through a custom protocol -->
|
<Option Name="RunUpdateTitle" Enabled="False" Value="" /> <!-- Will enable the toast to run any ConfigMgr Update Name through a custom protocol -->
|
||||||
<Option Name="Deadline" Enabled="False" Value="30-09-2019 08:00" /> <!-- Adds an additional group to the toast with text about the deadline of the OSUpgrade -->
|
<Option Name="Deadline" Enabled="False" Value="30-09-2019 08:00" /> <!-- Adds an additional group to the toast with text about the deadline of the OSUpgrade -->
|
||||||
|
|
@ -22,13 +21,13 @@
|
||||||
<Option Name="UsePowershellApp" Enabled="False" /> <!-- The app in Windows doing the actual notification - can't be both SoftwareCenter and Powershell -->
|
<Option Name="UsePowershellApp" Enabled="False" /> <!-- The app in Windows doing the actual notification - can't be both SoftwareCenter and Powershell -->
|
||||||
<Option Name="CustomAudio" Enabled="False" /> <!-- Enable or disable a custom speak scenario, where the text will be read out aloud -->
|
<Option Name="CustomAudio" Enabled="False" /> <!-- Enable or disable a custom speak scenario, where the text will be read out aloud -->
|
||||||
<Option Name="LogoImageName" Value="ToastLogoImageDefault.jpg" /> <!-- File name of the image shown as logo in the toast notoification -->
|
<Option Name="LogoImageName" Value="ToastLogoImageDefault.jpg" /> <!-- File name of the image shown as logo in the toast notoification -->
|
||||||
<Option Name="HeroImageName" Value="ToastHeroImageSecurity.jpg" /> <!-- File name of the image shown in the top of the toast notification -->
|
<Option Name="HeroImageName" Value="ToastHeroImageSecurity.jpg" /> <!-- File name of the image shown in the top of the toast notification -->
|
||||||
<Option Name="ActionButton1" Enabled="True" /> <!-- Enables or disables the action button. -->
|
<Option Name="ActionButton1" Enabled="True" /> <!-- Enables or disables the action button. -->
|
||||||
<Option Name="ActionButton2" Enabled="True" /> <!-- Enables or disables the action button. -->
|
<Option Name="ActionButton2" Enabled="True" /> <!-- Enables or disables the action button. -->
|
||||||
<Option Name="DismissButton" Enabled="False" /> <!-- Enables or disables the dismiss button. -->
|
<Option Name="DismissButton" Enabled="False" /> <!-- Enables or disables the dismiss button. -->
|
||||||
<Option Name="SnoozeButton" Enabled="False" /> <!-- Enabling this option will always enable action button and dismiss button -->
|
<Option Name="SnoozeButton" Enabled="False" /> <!-- Enabling this option will always enable action button and dismiss button -->
|
||||||
<Option Name="Scenario" Type="alarm" /> <!-- Possible values are: reminder | short | long -->
|
<Option Name="Scenario" Type="alarm" /> <!-- Possible values are: reminder | short | long -->
|
||||||
<Option Name="Action1" Value="ToastReboot:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
|
<Option Name="Action1" Value="ToastRunApplicationID:ScopeId_5197DD71-3116-4878-A26C-EA6155A28E9B/Application_91b60d2e-720e-46b4-8da9-5b56f9ff0177" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
|
||||||
<Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
|
<Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
|
||||||
<Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD -->
|
<Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD -->
|
||||||
<Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file -->
|
<Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue