Powerapps CLI have lots of function to support our daily activities. The most useful to me of course the command “pac plugin init” that automatically creates Plugin Project. Today, we will learn about Authentication and Solution commands to do export-import across the environment.
You can find the download link of the PowerApps CLI on this page. Once you have already downloaded the MSI and install it (in the folder that you want). Then you can try to open the command prompt and then run the “pac” command. If you got a response you are good to go, if not you can do it like me to set the Environment Variable (so you can call it anywhere across your machine).
Type on the start > Edit the Environment Variable > System will open System Properties > click on Environment Variables > copy and paste the location of the installed folder on the previous step.
Before we can export/import a solution, the first thing that we need to do is to connect with the environment we want to connect. To add a connection to the Dataverse environment, you just need to open a command prompt > type the below command:
pac auth create --name powermvps1 --url https://yourcrmurl.crm.dynamics.com --username firstname.lastname@example.org --password yourpassword
If your setting is correct, then you will get the below response(then you can run the command “pac auth list” to see the connected Environments):
From the above image, you can see that my system marks the environment the powermvps (index no 2) as the active environment. So every command that we will run, will be to this environment. But in case you want to change the environment, you can run the command “pac auth select –index 1” to set insurgo2 as the active environment.
Once the above steps are already in place, we just need to go running the below command for exporting:
pac solution export --path d:\\Solutions\Blog_Unmanaged.zip --name blog --managed false --include general
There are several parameters that you can apply here based on this link. You can set the name parameter to the correct solution, managed (true/false). In the latest version that I’m using (1.13.6+gf8c1356), I can’t use the targetversion flag. Then there is include flag also that can be set as thesethese values: autonumbering, calendar, customization, emailtracking, externalapplications, general, isvconfig, marketing, outlooksynchronization, relationshiproles, sales.
The next one is how to import the solution, you just need to import the below command:
pac solution import --path D:\Solutions\Blog_Unmanaged.zip --activate-plugins true --publish-changes true --async true
And below is the result once it finished importing:
There are lots of parameters that we can use here! Like convert-to-managed parameter that will allow a managed solution that is being imported into an environment to convert unmanaged components to managed state. The activate-plugins parameter to active the plugins once we finished importing.