Create logs under a folder matching the name of the application being installed

Hi, I’m new to using the product and in the process of trying to use PSAppDeployToolkit for some software distribution tasks.
My department has a policy where we log all application installs to a certain directory and under a folder which is named after the application.

i.e C:\Software\Logs\ “application name”

How can i do this? I know we can set custom logging for the toolkit and MSI, hoping to have it pickup the application name from the $appName variable in “Deploy-Application.ps1”

The toolkit builds the first part of its log file something like:

[string]$installName = $appVendor + ‘’ + $appName + '’ + $appVersion + ‘’ + $appLang + '’ + $appRevision

so I’m making sure to redefine those at the top of deploy-application.ps1 script before dot sourcing the toolkit for each script to separate the logs.

1 Like

I don’t think i explained that so well (sorry). I’m not really after a way to rename the log file itself more the fact creating a parent folder for all the logs to sit in based on that applications name.

i.e c:\software\logs\ “application name” \Microsoft_Notepad_123_EN_01.log

Oh I missed that part, I’ve got a few suggestions that should work for you. You can use variables in AppDeployToolkitConfig.xml:

ie: <Toolkit_LogPath>$envProgramData\YourCompany\Logs\$YourScriptName</Toolkit_LogPath>

Then you could build that $YourScriptName before dot sourcing the toolkit early in each Deploy-Application.ps1.

Another perhaps simpler option would be to rename individual Deploy-Application.ps1 files of your scripts to something descriptive of what it installs/does, then build your $YourScriptName with the file name with something like:

$YourScriptName = [io.path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Name)

Hope that helps

.

Thanks Johann, :slight_smile:

That’s working for us now. However have found that the below section of the code in the Deploy-Application.ps1 still creates a separate log in the parent directory “outside the newly created folder for the application” This is in the “POST-INSTALLATION” section of the script.

Display a message at the end of the install
If (-not $useDefaultMsi) { Show-InstallationPrompt -Message 'You can customize text to appear at the 
end of an install or remove it completely for unattended installations.' -ButtonRightText 'OK' -Icon 
Information -NoWait }

When we comment out this section it doesn’t create the additional log file. However we know our team will likely use this feature. Do you have any advise on where to look for this one? Seems strange that its not honouring the configured log path for MSI_LogPath, toolkit_TempPath or Toolkit_LogPath Options.

You’re welcome,

not too sure about the second log being created, I’ve never encountered this. Also, I have heavily modified the deploy-application.ps1 and the AppDeployToolkitExtensions.ps1 files that we use as a template at our company so its difficult for me to say in your particular case.

It might take a while to pinpoint but I’d suggest running your deploy-application.ps1 file in an elevated ISE session, add a breakpoint right before that script block and walk through the rest of the code line by line, periodically checking on log path variables values as you go to see where it might be ignored or modified.

1 Like

Thanks Johann. :slight_smile: