Issues with parameters while converting from old batch script installer

So, I am tasked with installing an ancient piece of software called Microsoft Dynamics AX 2012 (the client). I can successfully install with a batch file, but I am really hoping to be able to convert this old thing into something that I can run with PSADT v4.

The batch script line in question goes like this:

"\\onpremservername\Dynamics AX\2012 R2\Setup Files\setup.exe" parmfile="\\onpremservername\Dynamics AX\2012 R2\FWM Defaults x64.txt"

So, I figure it would be easy to get rid of the parmfile altogether and just put those parameters into the ArgumentList, but I am running into issues where PSADT doesn’t seem to like the parameters.

I successfully installed it without the parmfile in an admin command prompt window with, just to make sure that it took everything:

setup.exe AcceptLicenseTerms="1" RunMode="custom" ConfigurePrerequisites="1" HideUI="1" OptInCEIP="0" UseMicrosoftUpdate="1" InstallClientUI="1" ClientLanguage="en-US" ClientConfig="1" ClientInstallType="0" ClientConfigFile="C:\Temp\AX PROD - USR.axc" CreateClientDesktopShortcut="1" InstallOfficeAddins="1"

For movng over to PSADT, I threw the AX PROD - USR.axc file into the SupportFiles, and am hoping to just grab it from there, and am using the following with no luck, but I feel like I am formatting something incorrectly:

Start-ADTProcess -FilePath 'setup.exe' -ArgumentList "AcceptLicenseTerms='1' RunMode='custom' ConfigurePrerequisites='1' HideUI='1' OptInCEIP='0' UseMicrosoftUpdate='1' InstallClientUI='1' ClientLanguage='en-US' ClientConfig='1' ClientInstallType='0' ClientConfigFile='$($adtSession.DirSupportFiles)\AX PROD - USR.axc' CreateClientDesktopShortcut='1' InstallOfficeAddins='1'"

I’ve tried a few different combinations so far with no luck, but I am sure it is user error here. For the parmfile that the original batch file points at, it looks like this:

AcceptLicenseTerms = 1
RunMode = custom
ConfigurePrerequisites = 1
HideUI = 1
OptInCEIP = 1
UseMicrosoftUpdate = 1
InstallClientUI = 1
ClientLanguage = en-US
ClientConfig = 1
ClientInstallType = 0
ClientConfigFile= \\onpremserver\AX_Configs\x64\AX PROD - USR.axc
CreateClientDesktopShortcut = 1
InstallOfficeAddins = 1

This installs just fine, but I was reading the Installation Guide, and they state to put the parameters in a format like this:

ClientConfigFile="%Drive%:\<name of configuration file>.axc"

But, I am guessing there is something I am just not wrapping my head around with the arguments, or if I should just use the parmfile somehow.

I suspect your command line is very close to being correct, but there is one command that stands out that probably won’t work correctly because it is a variable wrapped in single quotes:

ClientConfigFile='$($adtSession.DirSupportFiles)\AX PROD - USR.axc'

N.B. Variables in single quotes (e.g. '$Variablename') will not be expanded to it’s content.
So looking at your command, I believe you should be using double quotes around any content that you need to be expanded, however as the whole ArgumentList string is wrapped in double quotes you need to escape the double quotes within the string or else the string is closed at that point (breaking the command).
Escaping a character in PowerShell is performed using the ` character (not to be confused with the single quote ' character)
Compare your original command:

Start-ADTProcess -FilePath 'setup.exe' -ArgumentList "AcceptLicenseTerms='1' RunMode='custom' ConfigurePrerequisites='1' HideUI='1' OptInCEIP='0' UseMicrosoftUpdate='1' InstallClientUI='1' ClientLanguage='en-US' ClientConfig='1' ClientInstallType='0' ClientConfigFile='$($adtSession.DirSupportFiles)\AX PROD - USR.axc' CreateClientDesktopShortcut='1' InstallOfficeAddins='1'"

With what I believe it should look like:

Start-ADTProcess -FilePath 'setup.exe' -ArgumentList "AcceptLicenseTerms='1' RunMode='custom' ConfigurePrerequisites='1' HideUI='1' OptInCEIP='0' UseMicrosoftUpdate='1' InstallClientUI='1' ClientLanguage='en-US' ClientConfig='1' ClientInstallType='0' ClientConfigFile=`"$($adtSession.DirSupportFiles)\AX PROD - USR.axc`" CreateClientDesktopShortcut='1' InstallOfficeAddins='1'"

Don’t worry, escaping multiple double quotes commonly comes up as an issue, with experience we all learn

1 Like

Still running into issues, but I would imagine it is closer now at least. It keeps coming up with “Execution failed with exit code [5]”. I am running this as admin on the test box, just to rule out permission issues.

<![LOG[[Initialization] :: *******************************************************************************]LOG]!><time="06:53:43.962-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: *******************************************************************************]LOG]!><time="06:53:43.962-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [MicrosoftCorporation_MicrosoftDynamicsAX_6.2.158.0_x86_EN_01] install started.]LOG]!><time="06:53:44.007-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [MicrosoftCorporation_MicrosoftDynamicsAX_6.2.158.0_x86_EN_01] script version is [1.0.0].]LOG]!><time="06:53:44.009-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [MicrosoftCorporation_MicrosoftDynamicsAX_6.2.158.0_x86_EN_01] script date is [2025-03-13].]LOG]!><time="06:53:44.011-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [MicrosoftCorporation_MicrosoftDynamicsAX_6.2.158.0_x86_EN_01] script author is [mreprogle-la].]LOG]!><time="06:53:44.013-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [Invoke-AppDeployToolkit.ps1] script version is [4.0.6].]LOG]!><time="06:53:44.013-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module version is [4.0.6].]LOG]!><time="06:53:44.015-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module imported in [2.6965919] seconds.]LOG]!><time="06:53:44.017-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module initialized in [2.6196298] seconds.]LOG]!><time="06:53:44.019-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] module path is ['C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit'].]LOG]!><time="06:53:44.019-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] config path is ['C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Config'].]LOG]!><time="06:53:44.021-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] string path is ['C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Strings'].]LOG]!><time="06:53:44.022-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: [PSAppDeployToolkit] session mode is [Native].]LOG]!><time="06:53:44.024-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Computer Name is [FWM-IntuneLab1.fwmrpc.com].]LOG]!><time="06:53:44.026-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Current User is [FWMRPC\mreprogle-la].]LOG]!><time="06:53:44.026-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: OS Version is [Microsoft Windows 11 Enterprise AMD64 10.0.26100.3194].]LOG]!><time="06:53:44.028-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: OS Type is [Workstation].]LOG]!><time="06:53:44.030-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Hardware Platform is [Virtual:VMware].]LOG]!><time="06:53:44.030-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Current Culture is [en-US], language is [EN] and UI language is [EN].]LOG]!><time="06:53:44.032-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: PowerShell Host is [ConsoleHost] with version [5.1.26100.2161].]LOG]!><time="06:53:44.033-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: PowerShell Version is [5.1.26100.2161 AMD64].]LOG]!><time="06:53:44.035-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: PowerShell CLR (.NET) version is [4.0.30319.42000].]LOG]!><time="06:53:44.035-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: *******************************************************************************]LOG]!><time="06:53:44.037-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Display session information for all logged on users:
?
?
NTAccount           : FWMRPC\mreprogle-la
SID                 : S-1-5-21-606747145-484061587-725345543-25538
UserName            : mreprogle-la
DomainName          : FWMRPC
SessionId           : 2
SessionName         : RDP-TCP#0
ConnectState        : WTSActive
IsCurrentSession    : True
IsConsoleSession    : False
IsActiveUserSession : True
IsUserSession       : True
IsRdpSession        : True
IsLocalAdmin        : True
LogonTime           : 3/12/2025 10:12:59 PM
IdleTime            : 00:00:02.2663800
DisconnectTime      :
ClientName          : RSCHMIDT1
ClientProtocolType  : RDP
ClientDirectory     : C:\Windows\System32\mstscax.dll
ClientBuildNumber   : 18363
]LOG]!><time="06:53:44.055-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The following users are logged on to the system: [FWMRPC\mreprogle-la].]LOG]!><time="06:53:44.057-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Current process is running with user account [FWMRPC\mreprogle-la] under logged on user session for [FWMRPC\mreprogle-la].]LOG]!><time="06:53:44.059-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Device has completed the OOBE and toolkit is not running with an active ESP in progress.]LOG]!><time="06:53:44.069-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: There is no console user logged on (user with control of physical monitor, keyboard, and mouse).]LOG]!><time="06:53:44.071-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The active logged on user is [FWMRPC\mreprogle-la].]LOG]!><time="06:53:44.075-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The current execution context has a primary UI language of [EN].]LOG]!><time="06:53:44.077-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: The following UI messages were imported from the config file: [en-US].]LOG]!><time="06:53:44.079-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Unable to find COM object [Microsoft.SMS.TSEnvironment]. Therefore, script is not currently running from a SCCM Task Sequence.]LOG]!><time="06:53:44.081-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Session 0 not detected.]LOG]!><time="06:53:44.085-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Installation is running in [Interactive] mode.]LOG]!><time="06:53:44.089-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Deployment type is [Install].]LOG]!><time="06:53:44.091-300" date="3-13-2025" component="Open-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Initialization] :: Module [PSAppDeployToolkit.Extensions] imported successfully.]LOG]!><time="06:53:44.217-300" date="3-13-2025" component="PSAppDeployToolkit.Extensions.psm1" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit.Extensions\PSAppDeployToolkit.Extensions.psm1">
<![LOG[[Install] :: [setup.exe] successfully resolved to fully qualified path [C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Files\setup.exe].]LOG]!><time="06:53:44.331-300" date="3-13-2025" component="Start-ADTProcess" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Working Directory is [C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Files].]LOG]!><time="06:53:44.381-300" date="3-13-2025" component="Start-ADTProcess" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Executing [C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Files\setup.exe AcceptLicenseTerms='1' RunMode='custom' ConfigurePrerequisites='1' HideUI='1' OptInCEIP='0' UseMicrosoftUpdate='1' InstallClientUI='1' ClientLanguage='en-US' ClientConfig='1' ClientInstallType='0' ClientConfigFile="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\SupportFiles\AX PROD - USR.axc" CreateClientDesktopShortcut='1' InstallOfficeAddins='1']...]LOG]!><time="06:53:44.385-300" date="3-13-2025" component="Start-ADTProcess" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Execution failed with exit code [5].]LOG]!><time="06:53:45.228-300" date="3-13-2025" component="Start-ADTProcess" context="FWMRPC\mreprogle-la" type="3" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Error Record:
-------------
?
Message               : Execution failed with exit code [5].
?
FullyQualifiedErrorId : ProcessExitCodeError,Start-ADTProcess
ScriptStackTrace      : at Start-ADTProcess<Process>, C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1: line 20256
at Install-ADTDeployment, C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Invoke-AppDeployToolkit.ps1: line 130
at <ScriptBlock>, C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Invoke-AppDeployToolkit.ps1: line 270
?
PositionMessage       : At C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Invoke-AppDeployToolkit.ps1:130 char:5
+     Start-ADTProcess -FilePath 'setup.exe' -ArgumentList "AcceptLicen ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]LOG]!><time="06:53:45.561-300" date="3-13-2025" component="Invoke-AppDeployToolkit.ps1" context="FWMRPC\mreprogle-la" type="3" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Invoke-AppDeployToolkit.ps1">
<![LOG[[Install] :: Displaying Dialog Box with message: Error Record:
-------------
?
Message               : Execution failed with exit code [5].
?
FullyQualifiedErrorId : ProcessExitCodeError,Start-ADTProcess
ScriptStackTrace      : at Start-ADTProcess<Process>, C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1: line 20256
at Install-ADTDeployment, C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Invoke-AppDeployToolkit.ps1: line 130
at <ScriptBlock>, C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Invoke-AppDeployToolkit.ps1: line 270
?
PositionMessage       : At C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\Invoke-AppDeployToolkit.ps1:130 char:5
+     Start-ADTProcess -FilePath 'setup.exe' -ArgumentList "AcceptLicen ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
]LOG]!><time="06:53:45.609-300" date="3-13-2025" component="Show-ADTDialogBox" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Install] :: Dialog Box Response: OK]LOG]!><time="06:54:20.191-300" date="3-13-2025" component="Show-ADTDialogBox" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Finalization] :: [MicrosoftCorporation_MicrosoftDynamicsAX_6.2.158.0_x86_EN_01] install completed with exit code [5].]LOG]!><time="06:54:20.252-300" date="3-13-2025" component="Close-ADTSession" context="FWMRPC\mreprogle-la" type="3" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">
<![LOG[[Finalization] :: *******************************************************************************]LOG]!><time="06:54:20.256-300" date="3-13-2025" component="Close-ADTSession" context="FWMRPC\mreprogle-la" type="1" thread="7232" file="C:\Users\mreprogle-la\Desktop\Intune Packages - In Progress\AX 2012 - slimmed\PSAppDeployToolkit\PSAppDeployToolkit.psm1">

Error 5 always means no access. Aka no permissions.

I think you ASSUME using an Admin account will give you the required permissions.

Try to make the setup.exe create it’s own Log file.

and/Or use the -Passthru parameter to capture output and error streams.

1 Like

I feel stupid for not knowing how to do this already. I tried adding -Passthru to the end, and I don’t see any change to the script running. I am just trying to run it as Admin in Powershell with Start-ADProcess and skipping the Invoke.exe to hopefully get some more information in the console. It also doesn’t change anything on the log side and just gives me the same error, but doesn’t say exactly where it is having permission issues.

If I run the installer manually, all seems to go through. Even when I run it with the HideUI parameter wiped, it brings up the installer and I can just run through like normal and install fine, but I have to pick through all of the settings and run the installer, so that skips the rest of the parameters.

Using this as a base:

You then tack on the -Passthru parameter and add a variable at the front to capture the output:

$Results = Start-ADTProcess -FilePath 'setup.exe' -ArgumentList "AcceptLicenseTerms='1' RunMode='custom' ConfigurePrerequisites='1' HideUI='1' OptInCEIP='0' UseMicrosoftUpdate='1' InstallClientUI='1' ClientLanguage='en-US' ClientConfig='1' ClientInstallType='0' ClientConfigFile=`"$($adtSession.DirSupportFiles)\AX PROD - USR.axc`" CreateClientDesktopShortcut='1' InstallOfficeAddins='1'" -Passthru

After that, use that variable to send the output and error streams to the PSADT log file:

Write-ADTLogEntry $($Results.ExitCode) | Out-string
Write-ADTLogEntry $($Results.STDOut) | Out-string
Write-ADTLogEntry $($Results.STDErr) | Out-string

The Out-string stuff is JIC. It filters out characters that don’t display well.

Sorry for the late response. I had to rebuild a test VM and get everything back in place, and just started back up on this. I first started getting errors due to the -Message parameter being null -

Write-ADTLogEntry : Cannot bind argument to parameter 'Message' because it is null.

So I figured it would need to have that, so I added it as this, but it still isn’t showing me any kind of different results in the logs or in my Powershell console:

Write-ADTLogEntry -Message "$($Results.ExitCode) | Out-string"
Write-ADTLogEntry -Message "$($Results.STDOut) | Out-string"
Write-ADTLogEntry -Message "$($Results.STDErr) | Out-string"

So, I think I might still be doing that part wrong to get the variable to output correctly.

Also, when I just try something like ‘Write-Output $Results’, nothing shows up there either, so it doesn’t seem to be holding anything in that variable, but still exits with that same

Start-ADTProcess : Execution failed with exit code [5].

Make the Setup.exe create its own log file. it should tell you what it doesn’t have access to.

I have 3-4 posts on “How to install, uninstall, and log silently” in the Tips-n-Tricks section

.

To avoid the “Message’ because it is null” thing, try this:

Write-ADTLogEntry "[$($($Results.ExitCode) | Out-string)]"
Write-ADTLogEntry "[$($($Results.STDOut) | Out-string)]"
Write-ADTLogEntry "[$($($Results.STDErr) | Out-string)]"

I haven’t tested it but if it works you should get [] instead of the error message.
If you do, that just means your setup.exe just doesn’t “talk” and you will have to enable logging on the setup.exe

1 Like