Compare commits

6 Commits

Author SHA1 Message Date
cfe71940e9 Upload files to "/" 2025-08-25 07:33:21 +00:00
3fbd29f609 Delete ConfigWinRM.ps1 2025-08-25 07:32:55 +00:00
43133f559b Verze 1.01 2025-08-12 11:06:17 +02:00
fc9bde78e0 Merge branch 'main' of https://git.totalservice.cz/public/ZBXWinRMConfig 2025-08-12 11:02:28 +02:00
9c3f731a54 zmena verze 1.06 2025-08-12 10:59:38 +02:00
ad9c726b29 Upload files to "/" 2025-07-30 07:34:18 +00:00

View File

@@ -3,7 +3,7 @@
<#PSScriptInfo <#PSScriptInfo
.VERSION 1.01 .VERSION 1.02
.GUID 14e0e777-6ba8-4f3f-b914-53c62e0a72aa .GUID 14e0e777-6ba8-4f3f-b914-53c62e0a72aa
@@ -41,6 +41,8 @@
Updated by David Norman <david@dkn.email> Updated by David Norman <david@dkn.email>
Version 1.01 - Fixed issue with HTTPS when certificate in HTTPS listener doesn't match the cert in local store Version 1.01 - Fixed issue with HTTPS when certificate in HTTPS listener doesn't match the cert in local store
Updated by Michal Horák Updated by Michal Horák
Verison 1.02 - Fixed issue when script fails on removing listeners if only HTTP listener exists (no HTTPS listener exists)
Updated by Michal Horák
#> #>
<# <#
@@ -647,8 +649,13 @@ if (-not $MyError -and ($RunningConfig.WinRMListeners | Where-Object { $_.Transp
Write-MyLog -LOGSeverity "INFO" -LOGMessage ("Removing existing WinRM HTTPS listener") Write-MyLog -LOGSeverity "INFO" -LOGMessage ("Removing existing WinRM HTTPS listener")
try try
{ {
Remove-WSManInstance -ResourceURI 'winrm/config/Listener' -SelectorSet $selectorset $existingHttpsListener = $RunningConfig.WinRMListeners | Where-Object { $_.Transport -eq "HTTPS" }
Write-MyLog -LOGSeverity "INFO" -LOGMessage ("WinRM SSL listener removed.") if ($existingHttpsListener) {
Remove-WSManInstance -ResourceURI 'winrm/config/Listener' -SelectorSet $selectorset
Write-MyLog -LOGSeverity "INFO" -LOGMessage ("WinRM SSL listener removed.")
} else {
Write-MyLog -LOGSeverity "INFO" -LOGMessage ("No WinRM HTTPS listener exists, nothing to remove.")
}
} catch } catch
{ {
Write-MyLog -LOGSeverity "ERROR" -LOGMessage ("Can't remove WinRM HTTPS listener. !!!") Write-MyLog -LOGSeverity "ERROR" -LOGMessage ("Can't remove WinRM HTTPS listener. !!!")
@@ -674,6 +681,9 @@ if (-not $MyError -and ($RunningConfig.WinRMListeners | Where-Object { $_.Transp
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
if (-not $MyError -and -not ($RunningConfig.WinRMListeners | Where-Object { $_.Transport -eq "HTTPS" } ) -and $CFG.WINRMHTTPS.ToLower() -eq "enable") if (-not $MyError -and -not ($RunningConfig.WinRMListeners | Where-Object { $_.Transport -eq "HTTPS" } ) -and $CFG.WINRMHTTPS.ToLower() -eq "enable")
{ {
# Check for existing HTTPS listener before creating certificate
$existingHttpsListener = Get-WSManInstance -ResourceURI winrm/config/listener -Enumerate | Where-Object { $_.Transport -eq "HTTPS" }
if (-not $existingHttpsListener) {
Write-MyLog -LOGSeverity "INFO" -LOGMessage ("Creating new WinRM HTTPS listener.") Write-MyLog -LOGSeverity "INFO" -LOGMessage ("Creating new WinRM HTTPS listener.")
try try
{ {
@@ -707,6 +717,9 @@ if (-not $MyError -and ($RunningConfig.WinRMListeners | Where-Object { $_.Transp
$MyError = $true $MyError = $true
} }
} }
} else {
Write-MyLog -LOGSeverity "INFO" -LOGMessage ("WinRM HTTPS listener already exists, skipping creation and certificate issuance.")
}
} }
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
if (-not $MyError -and $RunningConfig.WinRMListeners) if (-not $MyError -and $RunningConfig.WinRMListeners)