Last active
November 14, 2024 19:18
-
-
Save dotps1/e3b5bf37aea3a84b0a40c20d405cdc97 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
| <# | |
| .SYNOPSIS | |
| Ensures proper configuration of targeted Registry Key Property Values to prevent the LogMeIn Patch Management feature from interfering with the Windows Update subsystem. | |
| .DESCRIPTION | |
| There is a limitation on the WUAUSERV application that makes it a single user application. During the Patch Cycle of LabTech, if another application (LogMeIn) tries to invoke a call to it, | |
| It will cause the LabTech Patch Cycle to fail. This registry configuration will prevent the LogMeIn service from using the Windows Update subsystem. | |
| .INPUTS | |
| None. | |
| .OUTPUTS | |
| None. | |
| .NOTES | |
| Created by Thomas J. Malkewitz @dotps1 | |
| Version 1.3 | |
| ### Change Log### | |
| 20160608 - 1.0 - Script created. | |
| 20160609 - 1.1 - Added services to be restarted. | |
| 20160610 - 1.2 - Corrected registry key property value check, the object from Get-ItemProperty needed to be expanded. | |
| 20160614 - 1.3 - Added the Windows Update Automatic Update service to the list of services to be restarted. | |
| .LINK | |
| https://docs.labtechsoftware.com/knowledgebase/article/12175 | |
| .LINK | |
| http://dotps1.github.io | |
| #> | |
| # LogMeIn Patch Management Registry Key. | |
| $registryKey = 'HKLM:\SOFTWARE\LogMeIn\V5\PatchMgmt' | |
| # HashTable used to store the Key's Property Names and targeted Values. | |
| $propertyValues = @{ | |
| PatchMgmtEnabled = 0 | |
| WUAUpdate = 1 | |
| WUAStatus = 0 | |
| MicrosoftUpdate = 0 | |
| } | |
| # Array of LogMeIn Services. | |
| $services = @( | |
| 'LMIGuardianSvc', | |
| 'LogMeIn', | |
| 'LMIMaint', | |
| 'wuauserv' | |
| ) | |
| try { | |
| # If the LogMeIn Patch Managment Registry Key does not exist, assume LogMeIn is not installed. | |
| if (Test-Path -Path $registryKey -ErrorAction Stop) { | |
| # Loop through each Key (which represents each Property in the Registry Key) in the HashTable. | |
| # If the Property does not exist, attempt to create it. | |
| # If the value of the Property does not match the assigned value in the HashTable, correct it to be as such. | |
| foreach ($property in $propertyValues.Keys) { | |
| if (-not (Get-ItemProperty -Path $registryKey -Name $property -ErrorAction SilentlyContinue)) { | |
| try { | |
| New-ItemProperty -Path $registryKey -Name $property -Value $propertyValues[$property] -PropertyType DWORD -ErrorAction Stop | | |
| Out-Null | |
| Write-Output -InputObject "Successfully created the '$property' property in '$registryKey' registry key with a value of '$($propertyValues[$property])'." | |
| } catch { | |
| Write-Output -InputObject "Failed to create the '$property' property in '$registryKey' registry key with a value of '$($propertyValues[$property])'." | |
| } | |
| } elseif ((Get-ItemProperty -Path $registryKey -Name $property | Select-Object -ExpandProperty $property) -ne $propertyValues[$property]) { | |
| try { | |
| Set-ItemProperty -Path $registryKey -Name $property -Value $propertyValues[$property] -ErrorAction Stop | |
| Write-Output -InputObject "Successfully set the '$property' property in '$registryKey' registry key with a value of '$($propertyValues[$property])'." | |
| } catch { | |
| Write-Output -InputObject "Failed to set the '$property' property in '$registryKey' registry key with a value of '$($propertyValues[$property])'." | |
| } | |
| } | |
| } | |
| Write-Output -InputObject "Successfully configured all targeted properties in '$registryKey' registry key." | |
| # Restart the LogMeIn Services for the registry configruation to take effect. | |
| foreach ($service in $services) { | |
| if ((Get-Service -Name $service -ErrorAction SilentlyContinue).Status -eq 'Running') { | |
| try { | |
| Restart-Service -Name $service -ErrorAction Stop | |
| Write-Output -InputObject "Successfully restarted '$service'." | |
| } catch { | |
| Write-Output -InputObject "Failed to restart '$service'." | |
| } | |
| } | |
| } | |
| } else { | |
| Write-Output -InputObject "The '$registryKey' registry key does not exist." | |
| } | |
| } catch { | |
| Write-Output -InputObject "Failed to test if the '$registryKey' registry key exists." | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment