SCOM Powershell MP, Script configuration- DNSlint Alert

Fadil Ck 381 Reputation points
2023-06-14T11:24:00.7966667+00:00

Hi All,

I am trying to create an alert using Powershell MP in SCOM. The script is used to monitor DNSlint status. The DNSint cmd will output the status which we can export as html file.

The html file output contains following details for all the DNS servers in the domain.

Total number of CNAME records found on this server: 10

Total number of CNAME records missing on this server: 0

Total number of glue (A) records this server could not find: 0

If the above numbers does not match should trigger an alert. I have created a script which outputs the same as string, but I don't know how to add this in Powershell MP, using property bag feature.

$a = (Get-Content -Path 'D:\dnslint_CNAMEandGLUE.htm' |

Select-String -Pattern 'Total GUIDs found')

if ($a -match '10') {

Write-Host 'Total GUIDs found is 10'}

else {Write-Host 'GUIDs Failed'}

$b = (Get-Content -Path 'D:\dnslint_CNAMEandGLUE.htm' |

Select-String -Pattern 'Total number of glue')

if ($b -match '0') {

Write-Host 'Total number of glue (A) records this server could not find: 0'}

else {Write-Host 'Glue records failed'}

$c = (Get-Content -Path 'D:\dnslint_CNAMEandGLUE.htm' |

Select-String -Pattern 'CNAME records found')

if ($c -match '10') {

Write-Host 'Total number of CNAME records found on this server: 10'}

else {Write-Host 'CNAME records found failed'}

$d = (Get-Content -Path 'D:\dnslint_CNAMEandGLUE.htm' |

Select-String -Pattern 'CNAME records missing')

if ($d -match '0') {

Write-Host 'Total number of CNAME records missing on this server: 0'}

else {Write-Host 'CNAME records missing failed'}

Please see the attached output for the script if DNSLint status is Good.

success output

If the numbers are not matching script will output as below.

failed output

Kindly check the script and modify the same so that we can be alerted in SCOM if the data does not matches the desired output.

Thanks in Advance

Regards

Fadil CK.

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,599 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. XinGuo-MSFT 22,226 Reputation points
    2023-06-15T09:13:50.0966667+00:00

    Hi,

    Please refer to the screenshot below to replace your script:

    enter image description here

    scom_powershell_based_monitor02

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.