Wednesday, October 28, 2015

How to create a self-elevating PowerShell script that will run as administrator every time

Often there are various build processes or other automated tasks that run via PowerShell and need to be run as administrator.  If you forget to run it as administrator, it won't work, and you don't always know.

I came across a great blog post by Ben Armstrong that I have to share, where he's created a block of code you just prefix to the beginning of your PowerShell script that will re-launch it as administrator if it is not.  Check his post out here:

Here's a screenshot of the PowerShell code in case his blog goes down:

Tuesday, October 13, 2015

Without any customization, how to incrementally compile the CIL from the command line

With Dynamics AX 2012, you can start an incremental CIL compile from the command line (or Power Shell) without any customization.  This is useful if you have any automated processes that import XPOs frequently and you don't want to constantly build the full CIL.

Create an XML file with this data:

<?xml version="1.0" ?>
 <CompileIL incremental="true" />

Then save it in a place that is accessible from the AOS service account.  I saved it as "C:\IncrementalCIL.xml" on the AOS machine.

Then run this command, subbing in for your environment:

"C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe" \\MyNetworkShare\AOS.axc -startupcmd=autorun_C:\IncrementalCIL.xml

Some notes about the XML.  The version attribute must not be greater than your system's build, which can be found from calling xInfo::releaseVersion().

There are a TON more autorun features available, and you can use the following links or just dig into \Classes\SysAutoRun.

More information can be found at: