Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Governance and Administ...
Answered

Create Solution using PowerShell

(0) ShareShare
ReportReport
Posted on by 4

Hi

 

I need to create a solution, dataverse and app and customizations using PowerShell and Rest API

 

I am using this information:

Create, manage, and publish model-driven apps using code - Power Apps | Microsoft Learn

 

However, I am getting a 401 not authorized error message, so this information is not complete as it doesn't mention anything about security. Is there a published reference of the various APIs that can be used to create model-driven apps using REST and PowerShell

$token = '0000000-0000-000000000-1-000000'

$url = 'https://dev.api.crm3.dynamics.com/api/data/v9.2'
$method = 'POST'
$headers = @{
 'Content-Type'='application/json'
 'Authorization'='Bearer $token'
 'charset'='utf-8'
 'OData-MaxVersion'='4.0'
 'OData-version'='4.0'
 'Accept'='application/json'
 
}
$body = @{
 "name"="App20"
 "uniquename"="App20"
 "webresourceid"="953b9fac-1e5e-e611-80d6-00155ded156f"

}

Invoke-RestMethod -Method $method -Uri $url -Body($body|ConvertTo-Json) -Headers $headers -ContentType "application/json"

 

  • Verified answer
    klanguedoc Profile Picture
    39 on at
    Re: Create Solution using PowerShell

    Yes thanks, I finally figured out. I'm actually using a combination of PowerShell and pac cli which does the job nicely and it is easily integrated into Azure DevOps.

  • Verified answer
    EricRegnier Profile Picture
    8,714 Most Valuable Professional on at
    Re: Create Solution using PowerShell

    Hi @kevlangdoc,
    Did you manage to get this working? You'll need to authenticate and get the token before the rest request. Furthermore, whoever you authenticate with will need to have the rights privileges via security roles to create/manage Dataverse solutions. So for instance, if you're authenticating with yourself, you should have "System Administrator" role assigned to you and then you can authenti

    If you're using PowerShell then you can use the PAC cmdlets (Power Platform CLI) to simplify the code and work with solutions. Here's an example:

    # authenticate and can also use a SPN
    pac auth create --url https://myorg.crm.dynamics.com 
    
    # create solution
    pac solution init --publisher-name developer --publisher-prefix dev
    # or base on an existing solution
    pac solution clone --name sampleSolution
    
    # add component to a solution
    pac solution add-solution-component --component 00000000-0000-0000-0000-000000000000 --componentType 1 --solutionUniqueName sampleSolution


    More on PAC: https://learn.microsoft.com/en-us/power-platform/developer/cli/introduction#common-commands 
    Hope this helps!

  • joe_hannes_col Profile Picture
    1,843 Super User 2024 Season 1 on at
    Re: Create Solution using PowerShell

    Hello @kevlangdoc,

     

    You can find information about authentication in the documentation for the Web API.

    If you want to improve the documentation in the link you posted: The documentation is provided by Microsoft, and you can leave feedback at the end of the page.

Under review

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

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Governance and Administering

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 15 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 9

#3
bscarlavai33 Profile Picture

bscarlavai33 5 Super User 2025 Season 1

Overall leaderboard

Featured topics