Questo oggetto consente di monitorare le regole firewall in entrata per Condivisione file e stampanti e genera un avviso se le regole sono disabilitate o se le corrispondenti porte TCP sono bloccate.
Questo oggetto consente di monitorare le regole firewall in entrata per Condivisione file e stampanti e genera un avviso se le regole sono disabilitate o se le corrispondenti porte TCP 445 e 139 sono bloccate.
Questo monitor può entrare in uno stato d'integrità Critico per i motivi seguenti:
Windows Firewall non è in esecuzione.
Le regole firewall per Condivisione file e stampanti che fanno riferimento alla porta TCP 445 o 139 sono disabilitate.
Se lo stato d'integrità è sconosciuto, significa che il monitoraggio non è ancora iniziato per questo oggetto.
Determinare se Windows Firewall è abilitato
Per determinare se Windows Firewall è abilitato, eseguire la procedura seguente:
1. In un prompt dei comandi con privilegi elevati nel server in questione digitare: sc query mpssvc e premere INVIO.
2. Se il firewall non è in esecuzione, digitare il comando seguente: net start mpssvc.
Determinare se le regole firewall per le porte sono abilitate
Per determinare se le regole firewall per le porte sono abilitate, eseguire la procedura seguente:
1. Aprire il Pannello di controllo nel server in questione e fare clic su Sistema e sicurezza, quindi fare clic su Windows Firewall.
2. Nel riquadro a sinistra fare clic su Impostazioni avanzate e quindi su Regole in entrata.
3. Controllare se le regole seguenti sono abilitate e se Azione è Consenti:
Condivisione file e stampanti (NB-Session-In)
Condivisione file e stampanti (SMB-In)
4. Se le regole firewall non sono abilitate, fare clic sulla regola e, nel menu Azione, fare clic su Abilita regola.
Quando il problema si risolve, nel monitor viene reimpostato automaticamente lo stato integro.
Target | Microsoft.Windows.FileServices.Service.SMB.6.3 | ||
Parent Monitor | System.Health.AvailabilityState | ||
Category | Custom | ||
Enabled | True | ||
Alert Generate | True | ||
Alert Severity | Error | ||
Alert Priority | Normal | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.Windows.TimedScript.TwoStateMonitorType | ||
Remotable | True | ||
Accessibility | Public | ||
Alert Message |
| ||
RunAs | Microsoft.Windows.FileServices.MonitoringAccount |
<UnitMonitor ID="Microsoft.Windows.FileServices.Service.SMB.6.3.FirewallPortConfig" Accessibility="Public" Enabled="true" Target="Microsoft.Windows.FileServices.Service.SMB.6.3" ParentMonitorID="SystemHealth!System.Health.AvailabilityState" Remotable="true" Priority="Normal" RunAs="FileServices!Microsoft.Windows.FileServices.MonitoringAccount" TypeID="Windows!Microsoft.Windows.TimedScript.TwoStateMonitorType" ConfirmDelivery="false">
<Category>Custom</Category>
<AlertSettings AlertMessage="Microsoft.Windows.FileServices.Service.SMB.6.3.FirewallPortConfig.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>30</IntervalSeconds>
<SyncTime/>
<ScriptName>CheckFirewallPort.vbs</ScriptName>
<Arguments>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody>
Option Explicit
SetLocale("en-us")
Dim oArgs
Dim serverName
Set oArgs = WScript.Arguments
If oArgs.Count < 1 Then
Wscript.Quit -1
Else
serverName = oArgs(0)
End If
' NET_FW_PROFILE_TYPE2
Const NET_FW_PROFILE2_DOMAIN = &h0001
Const NET_FW_PROFILE2_PRIVATE = &h0002
Const NET_FW_PROFILE2_PUBLIC = &h0004
Const NET_FW_IP_PROTOCOL_TCP = &h0006
' Create the FwPolicy2 object
Dim fwPolicy2
Set fwPolicy2 = CreateObject("HNetCfg.FwPolicy2")
Dim fwCurrentProfile, fwCheckProfile
fwCurrentProfile = fwPolicy2.CurrentProfileTypes
fwCheckProfile = fwCurrentProfile And (NET_FW_PROFILE2_DOMAIN Or NET_FW_PROFILE2_PRIVATE)
Dim fwFileSharingPortsEnabled
fwFileSharingPortsEnabled ="False"
Dim rule
For Each rule in fwPolicy2.Rules
If (rule.Protocol = NET_FW_IP_PROTOCOL_TCP) And (rule.LocalPorts = "445") Then
If (Not rule.Enabled) And (rule.Profiles And fwCheckProfile ) Then
fwFileSharingPortsEnabled = "True"
Exit For
End If
End If
Next
Dim regularShareExist, objWMIService, colShares, objShare
regularShareExist = "False"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & serverName & "\root\microsoft\windows\smb")
Set colShares = objWMIService.ExecQuery("Select * from MSFT_SmbShare")
For each objShare in colShares
If objShare.Special = "False" Then
regularShareExist = "True"
Exit For
End If
Next
Dim portStatus
portStatus = "Disabled"
' Only if regular share exists and port 139/445 are not open will portStatus be returned as "Disabled"
If fwFileSharingPortsEnabled = "True" Then
portStatus = "Enabled"
Else
If regularShareExist = "False" Then
portStatus = "Enabled"
End If
End If
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue ("PortStatus", portStatus)
Call oAPI.Return(oBag)
</ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='PortStatus']</XPathQuery>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value Type="String">Enabled</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='PortStatus']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Enabled</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>