Detect AI Tools on Windows with Intune Remediations

To see which Windows devices in Intune have Claude Code, Codex CLI, Cursor, Ollama, AI extensions or MCP configs, create a detection-only Remediation with the free read-only script below and run it daily as SYSTEM. Devices with AI tools show With issues, and the detection output column names the tools and the users.

By Kuntur team · Published · Updated

Short version. Devices › Scripts and remediations › Remediations › Create. Upload kuntur-ai-inventory-intune.ps1 as the detection script, leave remediation empty, set logged-on credentials to No and 64-bit PowerShell to Yes, assign it to a device group on a daily schedule. Then open Device status and add the Pre-remediation detection output column.

Why discovered apps misses them

Intune's Discovered apps report is built mostly from installed programs and Store packages. Claude Code's native installer drops a single binary in %USERPROFILE%\.local\bin, Codex CLI and Gemini CLI usually arrive as global npm packages under %APPDATA%\npm, and Cursor or Windsurf install per user under %LOCALAPPDATA%\Programs. None of them needs an administrator, and a CLI installed through npm never registers as a program at all. So an empty Discovered apps list for "Claude" or "Codex" does not mean nobody has them.

Remediations close that gap without installing anything new: Intune already runs PowerShell on the device through the Intune Management Extension, and a detection script can look in every user profile.

How Remediations turn a script into a status

A Remediation is a pair of scripts, detection and remediation. This guide uses only the first. Four documented behaviours decide how the script is written:

So the script prints what it found, exits 1 when any AI tool is present, and Intune turns that into a status and a sortable column for the whole fleet.

Licenses and prerequisites

Without those licenses the Remediations page stays locked. The same script still works from anything that runs PowerShell as SYSTEM and keeps its output, for example Configuration Manager or PDQ.

The detection script

Windows PowerShell 5.1, read-only, no network calls. It checks the shared detection list described in the endpoint discovery guide in every profile: Claude Code, Codex CLI and Gemini CLI (native and npm), Cursor and Windsurf, Claude Desktop and ChatGPT Desktop (including Store packages), Ollama with its model count, LM Studio, AI extensions in VS Code, and the MCP config files of seven clients. For MCP files it counts server entries without reading commands, URLs or environment variables, so no token ends up in Intune.

Download kuntur-ai-inventory-intune.ps1 and read it before you upload it. Check it against this SHA-256:

aa0739ab0aee972a838a26c50601689374fbf909dbb9ab83a77fe28136455849
Get-FileHash .\kuntur-ai-inventory-intune.ps1 -Algorithm SHA256

These are the Intune-specific parts of the file: the output cap and the exit code that becomes the status.

$MaxOutput = 2000   # Intune shows a limited amount of output; stay under it.
...
if ($line.Length -gt $MaxOutput) { $line = $line.Substring(0, $MaxOutput - 3) + '...' }
...
Write-Output $line
if ($found) { exit 1 } else { exit 0 }

A device with findings reports a line like AI tools: Claude Code(2), Cursor(1), Ollama(1; 3 models), AI extensions(4 in 2), MCP configs(2; 5 servers) | users: alice,bob. The number in brackets is how many profiles have the tool. A clean device reports AI tools: none found in 3 profiles, which also tells you the script really ran and how many profiles it saw.

Want a file on each device too? Set [bool]$WriteJson = $true in the param block and the script also writes a short JSON summary to C:\ProgramData\KunturInventory\ai-inventory.json. It is off by default: Intune does not pass parameters to Remediation scripts, so the only way to turn it on is to edit the file, and a detection script should not leave files behind unless you decide it should.

Create the Remediation

  1. In the Microsoft Intune admin center, go to Devices › Scripts and remediations, open the Remediations tab and select Create.
  2. On Basics, give it a name the helpdesk will understand, for example AI tools inventory (detection only).
  3. On Settings, upload kuntur-ai-inventory-intune.ps1 as the Detection script file. Leave Remediation script file empty.
  4. Run this script using the logged-on credentials: No. Enforce script signature check: No, unless you sign scripts with a certificate your devices trust. Run script in 64-bit PowerShell: Yes.
  5. Add scope tags if your tenant uses them, so only the right admins see the output (it contains user names).
  6. On Assignments, pick a device group, start with IT's own devices, and set the schedule (next section). Assignment filters work here too, for example to skip shared kiosks.

The remediation script stays empty on purpose. Deleting a developer's tools automatically, without a policy they have seen, breaks their work and pushes people to install things where scripts do not look. If you later decide to block one specific tool, the Claude Code, Cursor and ChatGPT Desktop Intune guides cover that as a separate, deliberate step.

Which schedule to pick

Intune scheduleWhat it does with this scriptUse it when
OnceRuns a single time on each device, at the date and time you setA one-off audit, for example before a SOC 2 or ISO 27001 review
HourlyRuns every few hours, at the interval you setOnly during the first days of a rollout, while you check the output looks right
DailyRuns every N days at the time you setThe default for an ongoing inventory; pick a time when laptops are usually on

To check a single device right away, open it in Intune and use the Run remediation device action, then pick this package. It runs on that device as soon as it is reachable, without waiting for the schedule.

Read and export the results

  1. Open the package under Devices › Scripts and remediations. The overview counts devices With issues (AI tools found) and Without issues.
  2. Go to Device status and use Columns to add Pre-remediation detection output. That column holds the one-line summary per device.
  3. Select Export to get a CSV, then split the output on , and | in a spreadsheet to count devices per tool.

How to read it:

Settings that silently break it

SettingWhat goes wrong
64-bit PowerShell = NoThe script runs as a 32-bit process, where $env:ProgramFiles points to C:\Program Files (x86). The machine-wide Cursor and Ollama checks then look in the wrong folder and miss them.
Logged-on credentials = YesThe script runs as the signed-in user and can only read that user's own profile. Shared machines look cleaner than they are, and devices with nobody signed in report nothing.
Signature check = Yes, unsigned fileThe script never runs and the device shows Failed. Either sign it with your code-signing certificate or leave the check off.
Editing the script after uploadChanging the file changes its SHA-256. That is expected; compare against the hash above only before you edit, and keep your edited copy in version control.

Where the Intune approach stops

The gaps every fixed-path script shares (WSL distros, containers, browser-only use, unknown tools, install versus actual use) are listed once in the endpoint discovery guide. On top of those, Intune adds its own:

Roll out the Kuntur agent with Intune instead

The script gives you a daily line per device. The Kuntur agent, packaged as an Intune Win32 app (step-by-step deploy guide), reports a full inventory to one console: tool, version, user, whether it runs on the host, in WSL, in a container or a VM, MCP servers with their risky settings, and local models. You mark each tool approved or unauthorized once for the organization, and the console keeps the history the Device status page does not. Kuntur detects and reports; it never blocks or uninstalls anything.

To try it on one machine first, run the free scanner. It needs no account, uploads nothing, writes an HTML report of the same tools and ends with a link to the trial:

Windows (PowerShell). Prefer to read it first? Download scan.ps1, check it against the published hash and see what it does.

irm https://app.kuntur.io/scan.ps1 | iex

Free for up to 5 endpoints. Pro is US$3 per endpoint per month (or US$30 per endpoint per year) for 10 to 30 endpoints. The trial needs no credit card.

FAQ

Why doesn't Claude Code show up in Intune discovered apps?
Because it usually is not an installed program. The native installer puts one binary in the user's .local\bin folder and the npm install lives under %APPDATA%\npm; neither registers with Windows the way an MSI does. A detection script that checks those paths in every profile finds it.
Do I need a remediation script, or only detection?
Only detection. The script exits with 1 when AI tools are present, so those devices show With issues. Leave the remediation script empty; nothing is uninstalled or changed.
Should it run as SYSTEM or as the logged-on user?
As SYSTEM, the default, and in 64-bit PowerShell. As SYSTEM it can read every profile under C:\Users. As the logged-on user it only sees that user's own files.
Does the script collect secrets or file contents?
No. It checks whether paths exist, counts model manifests and extension folders, and counts the server entries in MCP config files without reading their values. The output holds tool names, counts and the profile names where something was found.
Can I use it without Windows E3 or E5 licenses?
Not as a Remediation, which Microsoft ties to those licenses. You can run the same file from Configuration Manager, PDQ or any RMM that runs PowerShell as SYSTEM and keeps the output.
Does it find tools installed inside WSL?
No. WSL distros keep their own file system, which this script does not open.

Sources

  1. Microsoft Learn: Use Remediations to detect and fix support issues
  2. Microsoft Learn: Remediations in Endpoint analytics
  3. Microsoft Learn training: Use Remediations to fix common device issues
  4. Claude Code docs: Advanced setup (install methods and locations)

More Intune guides: