24.05.2010, 15:05 | #1 |
Участник
|
saveenr: Dynamics AX 2009: Integrating AX with Powershell
Источник: http://blogs.msdn.com/saveenr/archiv...owershell.aspx
============== [UPDATE on 2010-05-15] To documentation for this powershell module has been placed here: http://cid-19ec39cb500669d8.skydrive...owershell.docx if you read this blog, you know I love command line interfaces – so this shouldn’t be a surprise. If you look at the Dynamics AX BI CodePlex project, you’ll see a Visual Studio 2008 project called “DynamicsAXPS”. This is a Powershell 2.0 module that lets you start exploring and controlling AX from the command line. In this post I’ll demonstrate how to use it. First, install Powershell 2.0 and start it. This module assumes you already have the AX Client installed on the machine and configured to connect to an AX Server. LOADING THE MODULE Once you build the project you’ll see these DLLs in the bin/debug directory… The module itself is the file called “DynamicsAXPS.dll” Now load it via this command Import-Module .\DynamicsAXPS.dll The warnings are because I have some non-standard cmdlet verbs defined. FINDING AX CMDLETS Get-Command -Module DynamicsAXPS INTERROGATING THE AOT Let’s get a node in the AOT – I’ll choose the CustTable $custtable = Get-AXNode "\Data Dictionary\Tables\CustTable" Of course we can pipe this to Out-GridView … $custtable = Get-AXNode "\Data Dictionary\Tables\CustTable" What about the child nodes under CustTable? Use Get-AXNodeChildItem Get-AXNodeChildItem "\Data Dictionary\Tables\CustTable" What if we wanted all the nodes underneath CustTable recursively? Just add the –Recurse flag. As you can see there are a lot of nodes Get-AXNodeChildItem "\Data Dictionary\Tables\CustTable" -Recurse Use Get-AXNodeProperties to get info about the properties for a specific node. Get-AXNodeProperties "\Data Dictionary\Tables\CustTable" LABELS If you need to get the value for a label us Get-AXLabel Get-AXLabel SYS11307 You can ask for multiple labels at the same time Get-AXLabel SYS11307,SYS125115 Getting MetaData for Tables, Enums, and EDTs There are three commands available. One for Extended Data Types. Get-AXEDTMetaData ABCModelType One for Enums: Get-AXEnumMetaData ABCModel One for Tables Get-AXTableMetaData CustTable If you are curious about the metadata, you can retrieve it from the metadata objects that are returns Here’s how to find out about the fields. $md = Get-AXTableMetaData CustTable OK, that’s a lot of fields, we can filter it down $md = Get-AXTableMetaData CustTable GETTING DATA FROM A TABLE $datatable = Get-AXTableData -Table CustTable -Fields * $datatable = Get-AXTableData -Table CustTable -Fields AccountNum,Name,Phone CREATE A TABLE VIA AN XPO Create-XPOForTable -Name Foo -Filename "D:\\Create_Table_Foo.xpo" -Fields A,B,C –FieldTypes INT,STRING,REALThis creates a simple XPO file that will create that table. Just import the XPO like any other and your table is ready ADD RECORDS TO A TABLE Add-AXRecord -Table Foo -Fields A,B,C -Values (1,"FOO",3.3)And if you open the table in AX … You’ll see the data has been placed in the table Источник: http://blogs.msdn.com/saveenr/archiv...owershell.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
Теги |
powershell, полезное |
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|