Intune Custom Compliance Script issues

rr-4098 1,701 Reputation points
2024-12-31T20:39:59.05+00:00

I am trying to setup a compliance policy to check that Crowdstrike is installed. I have tried running the script as the logged in user and not, etc.. same result. I know the script does not error out since I can run it on my workstation and it returns the correct value. Anyway regardless of what I do, Intune only shows "Not applicable" . Below is what the script and json file look like. Please note, I cannot take credit for this script which I found online and altered. I forget to mention the assignment is target to a group of test devices that are hybrid joined. :https://www.reddit.com/r/crowdstrike/comments/18cxacd/intune_custom_compliance_discovery_script_for/

$AVClient = 'CrowdStrike Falcon Sensor'
$AVProduct = Get-WmiObject -Namespace 'root\SecurityCenter2' -Class AntiVirusProduct | Where-Object { $_.displayName -eq $AVClient } | Select-Object -First 1
$AVSummary = New-Object -TypeName PSObject
If ($AVProduct) {
$hexProductState = [Convert]::ToString($AVProduct.productState, 16).PadLeft(6, '0')
$AVSummary | Add-Member -MemberType NoteProperty -Name "$AVClient" -Value $AVProduct.displayName
}
Else {
$AVSummary | Add-Member -MemberType NoteProperty -Name "$AVClient" -Value 'Error: Not Installed'
}
return $AVSummary | ConvertTo-Json -Compress
{
    "Rules": [
        {
            "SettingName": "CrowdStrike Falcon Sensor",
            "Operator": "IsEquals",
            "DataType": "String",
            "Operand": "CrowdStrike Falcon Sensor",
            "MoreInfoUrl": "https://www.crowdstrike.com/en-us/",
            "RemediationStrings": [
                {
                    "Language": "en_US",
                    "Title": "Incorrect Antivirus solution detected. Value discovered was {ActualValue}.",
                    "Description": "Install correct Antivirus solution."
                }
            ]
        }
    ]
}
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,598 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
5,414 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ZhoumingDuan-MSFT 14,870 Reputation points Microsoft Vendor
    2025-01-01T02:12:10.5833333+00:00

    @rr-4098, Thanks for posting in Q&A.

    From your description, I know you want to create a custom compliance policy to detect whether the Crowdstrike is installed but got some error.

    To solve this issue, here are some steps you can refer to.

    1.The device must be Windows 10/11 (excluding Windows 10/11 Home)

    2.The user has been assigned Intune license.

    3.Check if there exist other compliance policies assign to the device, unassign them and change the custom compliance policy assignment to user group.

    Also, I find sometimes it need to restart to make it work, you can try and see if the result will be different. Here is a link with more details:

    https://call4cloud.nl/2021/11/the-last-days-of-custom-compliance/

    Note: Non-Microsoft link, just for the reference.

    Hope above information can help you.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.