Monday, May 7, 2018

Windows PowerShell to deploy packages Dynamics 365 V9


Hello Troubled World,

I used Powershell to deploy some configuration data along with solutions into Dynamics 365 following https://msdn.microsoft.com/en-us/library/dn688182.aspx. It worked well for V8.2 and bellow.

Then with the V9 update I followed https://technet.microsoft.com/en-us/library/dn647420.aspx instructions and yet came across in below error w
hen running the RegisterXRMPackageDeployment.ps1 in powershell 3.0 as administrator, I get "Cannot verify the Microsoft .NET Framework version 4.5.2 because it is not included in the list of permitted versions" message and it continued exporting cmdlets.

The reason is Dynamics 365 V9 requires the .NET Framework 4.5.2 and we have to use TLS12 Security Protocol to use powershell in .net 4.5.2. 
When accessing services authenticated via AAD (Azure Active Directory) it  requires TLS 1.2 protocol. Somehow power-shell doesn't get the machine's setup for TLS 1.2 and hence we have to manually give the configurations.

by adding below line before accessing CRM will provide the required permissions.

[System.Net.ServicePointManager]::SecurityProtocol = 
[System.Net.SecurityProtocolType]::Tls12

eg:

Add-PSSnapin Microsoft.Xrm.Tooling.Connector
Add-PSSnapin Microsoft.Xrm.Tooling.PackageDeployment 
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$CRMConn = Get-CrmConnection -InteractiveMode
Import-CrmPackage -CrmConnection $CRMConn -PackageDirectory D:\test\ -PackageName testPkg.dll -Timeout 1:00:00:00 -Verbose





No comments:

Post a Comment