Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - try {
 - # Define the registry path and the value name
 - $regPath = "HKLM:\SYSTEM\ControlSet001\Services\ScreenConnect Client (XXXXXXXXXXXXXXXX)"
 - $valueName = "ImagePath"
 - # Check if the registry key exists
 - if (Test-Path $regPath) {
 - # Try to read the current value of the registry key
 - $currentValue = (Get-ItemProperty -Path $regPath -Name $valueName).$valueName
 - if ($currentValue) {
 - # Replace "p=443" with "p=8041"
 - $newValue = $currentValue -replace "p=443", "p=8041"
 - # Update the registry with the new value
 - Set-ItemProperty -Path $regPath -Name $valueName -Value $newValue
 - Write-Host "Updated 'ImagePath' value successfully!" -ForegroundColor Green
 - try {
 - Restart-Service -Name "ScreenConnect Client (XXXXXXXXXXXXXXXX)" -Force
 - Write-Host "ScreenConnect service restarted." -ForegroundColor Green
 - }
 - catch {
 - Write-Host "ScreenConnect service could not be restarted." -ForegroundColor Red
 - }
 - } else {
 - Write-Warning "The registry entry '$valueName' does not contain a valid value."
 - }
 - } else {
 - Write-Error "The registry path '$regPath' does not exist."
 - }
 - } catch {
 - # Catch any unexpected errors
 - Write-Error "An error occurred: $_"
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment