Supercharging Dataverse Automation with Rnwood.PowerShell: A Smarter Alternative to MCP

Why Devs and Admins Should Care - Even with AI and MCP in Play

cover

Tired of clicking for the 100th time (even with XrmToolbox)? Love Dataverse MCP AI-assisted workflows, but worried they are slow and unreliable? There’s a better way!

Rnwood.Dataverse.Data.PowerShell is a PowerShell module that lets you work with Microsoft Dataverse to query and manipulate data, solutions and customisations (tables, columns, forms, views, etc). You can write scripts or interactively do these things in your terminal.

For instance, you could use it to:

  1. migrate/transform data during deployment when the structure of your tables/columns needs to change
  2. complete development tasks efficiently, like finding all views containing column ‘x’ and replacing them with ‘y’ and ‘z’

It’s super flexible, so these are just two examples of the types of things you could string together. The sky is the limit.

Why do I want this? I’ve already got…

OK, let’s cut to the chase about what some of you are thinking…

“I’ve got the Dataverse MCP provider by Microsoft. That does this!”

Completing one-off ad-hoc tasks using an AI agent using MCP tools directly is great for exploration and simple/short tasks, but:

  • When you need an accurate and repeatable process (i.e. test it and rely on it doing the same), AI-driven processes simply cannot do that as they are non-deterministic by nature. They always do the wrong thing much more than 0% of the time, and no amount of testing can prevent it. Every bit of data going through the LLM is at risk of being messed up. No way I’m letting that touch production systems/data for most scenarios, even if I tested it.
  • When you want to complete a larger task (e.g. update 50 records), AI-driven simple MCP tools are slow and can be unreliable . Again, this is due to the nature of the technology. Each MCP tool call can often only do one thing - e.g. update one record. Repeating the same thing x times involves calling them that many times, and doing more complex tasks involves multiple MCP tools with all the data flowing through the LLM. AI agents often run out of context window space before completing the task and start to go off track. LLMs are nowhere near 100% accurate when doing this.

Based on this, my view is that it’s better to use AI agents to help us write scripts/programs that complete the task rather than using them to actually execute the individual steps in real time using MCP. Quite a bit of the time, we’re just looking for help from AI in designing data operations that we want to be repeated deterministically rather than wanting it to predict/suggest/summarise the data that is flowing through — where AI actually adds value. Scripting is a powerful alternative because it allows the AI to design and execute/hand off the process, without forcing it to handle the data when it runs. You can then take that away and confidently use it time after time without the drawbacks that using AI every time brings.

It turns out I’m not alone in this conclusion:

Engineering at Anthropic - Agents scale better by writing code to call tools instead

The Cloudflare Blog - Code Mode: the better way to use MCP

Microsoft - Use code interpreter to generate and execute Python code

Making your process repeatable using a script that the AI has helped you write is the best way to make sure it’s fast, repeatable and reliable and that you’re not at the mercy of the non-deterministic gods.

OK, the next thing some of you might be thinking…

“I’ve got XrmToolbox and its many tools for this!”

XrmToolbox is great for truly one-off tasks, but when you want them to be repeatable (accurately) and without a human driving them, it falls apart. Additionally, each tool can often do only one thing, meaning you need to string together a number with you joining the dots, transforming data and shuffling files around.

Making your process repeatable using a script is the best way to make sure it’s fast, repeatable and reliable and ensures human error is minimised. It’s also way more flexible than typical “one job” tools like XrmToolbox.

Read my previous discussion about this

Last but not least, are you thinking…?

“I can’t write PowerShell scripts, it’s too hard”

Now that’s a great job for your AI assistant to help you with! You’ll pick up the basics in no time. See the sections below for some further guidance, and even using a coding agent to drive it directly.

Using it with your AI coding agent

Responsible AI warning

Like all agents, be careful to review what your agent is proposing to run before running it! As above, it’s best to stick with using your AI to make and test scripts in your non-production, test them and then just run the script (no AI) against production.

This module works really well with AI coding agents like GitHub Copilot and Claude Code. Just make sure they have the instructions they need to use it in your AGENTS.md file.

AGENTS.md
To interact with Dataverse you must use the PowerShell module at https://github.com/rnwood/Rnwood.Dataverse.Data.PowerShell.
1) Make sure the user is connected using `Get-DataverseWhoAmI`.
If not, run `Get-DataverseConnection -interactive -SetasDefault` which will allow the user to select and connect.
2) Run `Get-Command -Module Rnwood.Dataverse.Data.PowerShell` to list the command you can use
3) Before using each command, read the help using `Get-Help CommandName -Detailed | Out-Host`

These coding agents can drive PowerShell and the module directly. You just need install it first in whatever version of PowerShell your coding agent is driving - follow these instructions

You can, of course, use other non coding agent AI services like ChatGPT, but you’ll get the best results from a coding agent that can directly execute and get feedback from the steps it takes without you doing the legwork. See details below for guidance on using these efficiently.

What about Copilot Studio?

See the links I posted above about why AI agent-orchestrated MCP is challenging for these kinds of tasks and what the leaders are thinking can improve it. We need that to play out before we’ll see CPS able to script and orchestrate MCP/other tools without using AI to drive it all.

So right now, I don’t see CPS as the best tool for developers/makers/administrators to complete their own work with. Whilst it’s easy to get started, the limitations add up quickly, and the results are poor. I’d strongly encourage you to explore the general-purpose coding agents above and others and experience this boost.

Making it easy to get started without a coding agent

So how can you get started easily with this world of scripting if you’ve not got access to one of these fancy AI coding agents like Claude Code? Say, just by using ChatGPT to help you with some cut-and-pasting in and out of it? Or maybe you’re old-school and you want to go it alone and actually write it yourself?

Version 2.x of Rnwood.Dataverse.Data.PowerShell introduces an XrmToolbox plugin to make it as trivial as possible to get started.

  1. Install the XrmToolbox plugin - search for PowerShell Scripting Workspace and open the tool.
  2. Connect to an environment as you normally would.
  3. The PowerShell session is automatically connected to the XrmToolbox connection with the module loaded and provides auto-completion assistance. Anything you run will use that connection automatically.

If you’re using an AI assistant, let them know to look at https://github.com/rnwood/Rnwood.Dataverse.Data.PowerShell/ to grab the info they need. (If you don’t, you’ll get terrible assistance due to lack of training data).

Example prompt: Fetch the help from https://github.com/rnwood/Rnwood.Dataverse.Data.PowerShell and write me a script to get all contact records with a first name of ‘Nathan’ and a lastname of ‘Rose’ and set their department to ‘MVP’

Responsible AI warning

Like all AI, be careful to review what your agent is proposing you run before running it! As above, it’s best to stick with using your AI to make and test scripts in your non-production, test them and then just run the script (no AI) against production.

  1. Now enter this in the editor:

    Terminal window
    Get-DataverseRecord -tablename contact -top 10 | convertto-json | out-file contacts.json

    You’ll notice that as you enter this (assuming you typed it in), the editor will help you with auto-completion suggestions. This enables you to discover the commands that are available and all of their options.

  2. Now press the ‘Run’ button. Your script will run in the terminal below.

Congratulations, you just implemented a process to export some contacts to a JSON file! (to see the file contents run start contacts.json)

Explanation

In PowerShell the |s in the script create a pipeline down which data flows kind of like a loop. Get-... reads the records and outputs them as objects, Convert- turns that into JSON and Out-File saves that all to a file. Read more about this here.

Now imagine that there are 100s of commands (cmdlets), each with many options (parameters) that vary what they do, in this module, standard PowerShell and the wider PowerShell ecosystem. Imagine the possibilities when combining them - this is why PowerShell scripting is so powerful.

Now you’ve got your tested script, you can save it and re-use it any time, safe in the knowledge that AI isn’t going to change it.

Once you’re happy and you want to run your scripts outside of XrmToolbox, follow the full module installation quick start or see the other documentation that explains how you can run it as part of your deployment process.

Like It? I need your help

If you like this module, please spread the word in your community groups, videos/podcasts and blog posts. Share how you turned your manual process, or XrmToolbox multi-step process into a script. Share how much further it took you than the Dataverse MCP provider… The good, the bad and the ugly!

Report bugs, suggest features and discuss ideas and general usage at GitHub.

If you’ve got the skills, you are welcome to contribute features and bug fixes as PRs.

Still not convinced scripting is the way forward?

Let’s talk! Invitations to discuss in groups, videos, and podcasts are welcome.