DEV Community

Riccardo Gregori
Riccardo Gregori

Posted on

2

Invoke Dataverse AI Actions via Powershell

A few days ago, I was 🛠️ thinking to create a command for PACX that allowed me to call via command line the new Dataverse AI functions 🛠️.

But I'm lazy, so I try to avoid reinventing the wheel when there is one there already available that just fits my needs.

Here is how you can invoke the 🤖 Dataverse AI 🤖 actions via Powershell leveraging Microsoft.Xrm.Data.PowerShell:

# setup a connection towards your dataverse environment
$conn = Get-CrmConnection -ConnectionString $connStr

# invoke the action
$response = Invoke-CrmAction -conn $conn -Name AIReply -Parameters @{ Text = "Compute the square root of PI" }

# print out the response
$response
Enter fullscreen mode Exit fullscreen mode

The square root of PI


Recently I've also known about this powershell library by Rob Wood and... this is how to do the same via Rnwood.Dataverse.Data.PowerShell.


# install the powershell module
Install-Module Rnwood.Dataverse.Data.PowerShell -Scope CurrentUser

# setup a connection towards your dataverse environment
$c = Get-DataverseConnection -url https://myorg.crm4.dynamics.com -interactive

# create the request
$request = new-object Microsoft.Xrm.Sdk.OrganizationRequest "AIReply"
$request["Text"] = "Can you compute the square root of PI?"
$response = Invoke-DataverseRequest -connection $c -request $request

# print out the response
$response

Enter fullscreen mode Exit fullscreen mode

Et voilà:

The square root of PI

Of course it works with any organization request 😎

References:

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs