Problem with Local Powershell Check

So here is my script:

$Checks = Get-WmiObject -Namespace root\microsoftdfs -Class dfsrreplicatedfolderinfo|Select State,ReplicatedFolderName
Foreach($Check in $Checks)
{
$Name = ($Check).ReplicatedFolderName
if(($Check).State -eq 5)
{
Echo “2 DFS-State - Replicationfolder ‘$Name’ DFS State is degraded.”
}
elseif (($Check).State -eq 3)
{
Echo “1 DFS-State - Replicationfolder ‘$Name’ DFS State is in Auto Repair.”
}
elseif (($Check).State -eq 2)
{
Echo “1 DFS-State - Replicationfolder ‘$Name’ DFS is in initial Sync.”
}
else
{
echo “0 DFS-State - Replicationfolder ‘$Name’ DFS State is fine.”
}
}

The script works fine and checkmk is discovering the Service. My Problem is it is just showing the first Output of the Script and not all the other ones as another Service.

Anyone able to help?

Your script only produces one service check named DFS-State.

If you have multiple replicated folders you have to integrate the folder name into the service name to make it unique.

The service description (name) has to be unique for each service check per host.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.