Skip to main content

Notifications

Business Central forum
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

How to use Windows Powershell in Business Central onprem?

Posted on by 5

Hello everyone!

I'm trying to execute a basic powershell script in BC:

dotnet
{
    assembly("System.Management.Automation")
    {
        type("System.Management.Automation.PowerShell"; "PowerShell") { }
    }
}

pageextension 50164 DotNetItem extends "Item List"
{
    trigger OnOpenPage()
    var
        Shelly: DotNet PowerShell;
    begin
        Shelly := Shelly.Create();
        Shelly.AddScript('C:\Users\MartinRuhland\Documents\Zeug\Testscript.ps1');
        Shelly.Invoke();
    end;
}

The code compiles, but throws a runtime error: "Ambiguous Match found"

The script itself works fine. Am i missing something? Is it even possible?

Regards

Martin

Categories:

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans