AXForum  
Go Back   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Forgotten Your Password?
Register Forum Rules FAQ Members List Today's Posts Search

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 17.11.2016, 12:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,646 / 848 (80) +++++++
Join Date: 28.10.2006
goshoom: Installing deployable packages with Powershell
Источник: http://dev.goshoom.net/en/2016/11/in...th-powershell/
==============

Installing deployable packages to an AX 7 environment can often be done just by a few clicks on LCS (as described in Apply a deployable package on a Microsoft Dynamics 365 for Operations system). Unfortunately the situation isn’t always that simple and you may have to install the package manually, using the process explained in Install a deployable package. It consists of quite a few manual steps and where there are repeated manual steps, one should always consider automation.

I’ve built a few Powershell functions to help with these tasks:

#region Parameters$folder = 'C:\Temp'$archiveFileName = 'Updates.zip'$runbookId = 'MyRunbook1'$ErrorActionPreference = 'Stop'#endregion #region Derived values$file = Join-Path $folder $archiveFileName$runbookFile = Join-Path $folder "$runbookId.xml"$extracted = Join-Path $folder ([System.IO.Path]::GetFileNameWithoutExtension($archiveFileName))$topologyFile = Join-Path $extracted 'DefaultTopologyData.xml'$updateInstaller = Join-Path $extracted 'AXUpdateInstaller.exe'#endregion Function ExtractFiles{ Unblock-File $file Expand-Archive -LiteralPath $file -Destination $extracted} Function SetTopologyData{ [xml]$xml = Get-Content $topologyFile $machine = $xml.TopologyData.MachineList.Machine # Set computer name $machine.Name = $env:computername #Set service models $serviceModelList = $machine.ServiceModelList $serviceModelList.RemoveAll() $instalInfoDll = Join-Path $extracted 'Microsoft.Dynamics.AX.AXInstallationInfo.dll' [void][System.Reflection.Assembly]::LoadFile($instalInfoDll) $models = [Microsoft.Dynamics.AX.AXInstallationInfo.AXInstallationInfo]::GetInstalledServiceModel() foreach ($name in $models.Name) { $element = $xml.CreateElement('string') $element.InnerText = $name $serviceModelList.AppendChild($element) } $xml.Save($topologyFile)} Function GenerateRunbook{ $serviceModelFile = Join-Path $extracted 'DefaultServiceModelData.xml' & $updateInstaller generate "-runbookId=$runbookId" "-topologyFile=$topologyFile" "-serviceModelFile=$serviceModelFile" "-runbookFile=$runbookFile"} Function ImportRunbook{ & $updateInstaller import "-runbookfile=$runbookFile"} Function ExecuteRunbook{ & $updateInstaller execute "-runbookId=$runbookId"} Function RerunRunbook([int] $step){ & $updateInstaller execute "-runbookId=$runbookId" "-rerunstep=$step"} Function SetStepComplete([int] $step){ & $updateInstaller execute "-runbookId=$runbookId" "-setstepcomplete=$step"} Function ExportRunbook{ & $updateInstaller export "-runbookId=$runbookId" "-runbookfile=$runbookFile"}






When you set parameters (such as the name of your package file) and run the script, you can then execute whole process by the following list of function calls:

ExtractFilesSetTopologyDataGenerateRunbookImportRunbookExecuteRunbook






If needed, you can also use RerunRunbook and SetStepComplete (e.g. SetStepComplete 10).

Note that SetTopologyData takes data just from the current machine, but you can borrow the code and modify it, if you need something more sophisticated.

This should make things a bit easier and reduce unnecessary errors such as mistyped runbook IDs.



Источник: http://dev.goshoom.net/en/2016/11/in...th-powershell/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Similar Threads
Thread Thread Starter Forum Replies Last Post
jaestevan: PowerShell para la administración automática de Dynamics AX 2012 (PS-II) Blog bot DAX Blogs 0 28.06.2016 17:11
goshoom: Preview of Release Management Blog bot DAX Blogs 0 15.10.2015 12:11
goshoom: Creating AX users in Powershell Blog bot DAX Blogs 0 30.04.2014 16:11
goshoom: Powershell management cmdlets Blog bot DAX Blogs 0 04.01.2014 18:15

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Рейтинг@Mail.ru
All times are GMT +3. The time now is 01:50.
Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Contacts E-mail, Advertising.