web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create Solution using ...
Power Apps
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"

 

I have the same question (0)
  • joe_hannes_col Profile Picture
    1,843 Super User 2024 Season 1 on at

    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.

  • Verified answer
    EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    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!

  • Verified answer
    klanguedoc Profile Picture
    39 on at

    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.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#2
11manish Profile Picture

11manish 205 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard