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”
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.
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:
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.
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.
I had this same issue with Show-InstallationPrompt creating a 2nd log file. When the -nowait parameter is used, the AppDeployToolkitMain.ps1 script is called ‘asynchronously.’ Because my config XML file had this line: “<Toolkit_LogPath>$envWinDir\options\logs$AppVendor $AppName $AppVersion</Toolkit_LogPath>” using variables with values set in Deploy-Application.PS1, AppDeployToolkitMain.ps1 did not evaluate the following line to include the variables. “[String]$configToolkitLogDir = $ExecutionContext.InvokeCommand.ExpandString($xmlToolkitOptions.Toolkit_LogPath)” This made a 2nd log file.
My solution was to add the following line in the AsyncToolkitLaunch section in the body of AppDeployToolkitMain.ps.
$configToolkitLogDir = ($configToolkitLogDir.trim() + $ReferredInstallTitle)
Afterwards, the log directory, and therefore the log, remained the same when Show-InstallatPrompt ran asynchronously.