How to write custom commands to logfile?


Maybe this is a newbie question but I’m trying to run a powershell command in the post-installation section. Something like Move-Item -Path $path2 -Destination $path -Force. How can I make it verbose and also log this command into the logfile?

Thanks for building a great script/solution!

Because Move-Item is a powershell NATIVE command, it does what it does.

you could use write-log to announce that you are about to move a file and that’s about it.

Roll your own functions via the AppDeployToolkitMain.psi - that’s what we do/did.

The toolkit generates extensive logging for all toolkit and MSI operations. If you use the toolkit function Copy-File (and perhaps Remove-File on the old file) this would give you the following log entry in the log file for the script (found in %windir%\logs\software):

[Post-Installation] :: Copy file in path [SOURCEFOLDER\Example.ext] to destination [DESTINATIONFOLDER\Example.ext]	Copy-File	30.07.2015 12:00:00	5644 (0x160C)