Execute-MSI Log path change

Hi guys,
I have set the logging folder to “C:\PSADT\Install” in XML to log the installation. My question is how do I log uninstallation of an MSI to “C:\PSADT_Uninstall\Uninstall.log”

since the installation log folder is different from uninstallation - I am sure there’s a workaround instead of editing the Maintoolkit.

Thanks! :slight_smile:

When you set the logging folder in the XML you are setting the $configToolkitLogDir variable in AppDeployToolkitMain.ps1

You could try setting $configToolkitLogDir early in Deploy-Application.ps1 right after it runs AppDeployToolkitMain.ps1

If that doesn’t work, I can help you modify AppDeployToolkitMain.ps1 to set the $configToolkitLogDir variable depending if you are installing or uninstalling.

Hi,
Thanks for the response. I am not that great with PS, just enough to do the job.
I like the idea to set $configToolkitLogDir location depending if “Deploy-Application.exe Install” is executed or “Deploy-Application.exe Uninstall”.

If it doesn’t work or has weird side effects, we’ll bring that Install/Uninstall decision in the Main.PS1
but then you’ll have your very own fork of PSADT.

PS: Don’t sweat the “just enough to do the job” part. That’s how I started with my PSADT fork. I’ve learned a lot from the PSADT code and now I can help most people.

Hi,
The log file is now in both directories instead of just being in one (C:\PSADT_Uninstall).

$ConfigToolKitLogDir and $ConfigMSILogDir that I am trying to post in other folder for uninstall.
Can we have it in just Uninstall directory so I can delete the Install dir that it creates during Installation process?

So this means we must modify AppDeployToolkitMain.ps1 and AppDeployToolkitConfig.xml to get what you want.

Step 1: In AppDeployToolkitConfig.xml add the path where you want the uninstall log files to go in a new XML entry:

<Toolkit_UNLogPath>C:\PSADT_Uninstall</Toolkit_UNLogPath>|

.
Step 2:In AppDeployToolkitMain.ps1 add code to read this new XML entry if we are uninstalling.
below this line:

[string]$configToolkitLogDir = $ExecutionContext.InvokeCommand.ExpandString($xmlToolkitOptions.Toolkit_LogPath)

add:

If ($deploymentType -ieq 'Uninstall') {
	[string]$configToolkitLogDir = $ExecutionContext.InvokeCommand.ExpandString($xmlToolkitOptions.Toolkit_UNLogPath)
}

The catch: You will now have a customized version of PSADT. Everytime a new version of PSADT is released, you will have to insert these changes. I use WinMerge from 2013 to sync up my 150+ changes. You have only 2.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.