Deployment · Dynamics CRM 2016 · Power Shell · Tools

CRM 2016: Use PowerShell to run Package Deployer

Package Deployer is a great tool to deploy your Dynamics CRM solutions. However, it normally requires human to operate the tool and seldom automated.

Here is how to automate the deploy process using PowerShell.

Step 1 – Register XRM Tooling
First step is to install XRM Tooling SnapIn. Follow this article Use PowerShell cmdlets for XRM tooling to connect to Dynamics 365.

Step 2 – Deploy using PowerShell

Add-PSSnapin Microsoft.Xrm.Tooling.Connector
Add-PSSnapin Microsoft.Xrm.Tooling.PackageDeployment

$packageDirectory = Get-Location
$packageName = "MyPackageDeployer.dll"
$username = "administrator@mycrm.onmicrosoft.com"
$password = "mypassword"
$orgName = "myOrgName"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr

$CRMConn = Get-CrmConnection -DeploymentRegion Oceania -OnlineType Office365 -OrganizationName $orgName -Credential $Cred

Import-CrmPackage -CrmConnection $CRMConn -PackageDirectory $packageDirectory -PackageName $packageName -Verbose

The drawback of deploying this way is that it requires Administrator privilege to install those SnapIn, something not available on TFS Online.

Cheers,
Sy

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s