Right way of logging

Hi Guys good afternoon!

I’m trying to install and for logging purposes, I’m trying to make my log appear on my psadt log File…

I have tested both ways and it looks like I don’t get it at the psadt log file…

-First way
#Write-Log -Message "Checking if there's any app installed" -Severity 2 -AppendToLogFile $true

-Second Way
Write-Log -Message "Checking if there's any app installed" -Severity 2 -Source ${CmdletName} -DebugMessage
Remove-MSIApplications -Name "Altec DataPrint" -Exact -EA 0
Don’t get any error but no message.

How do you guys make it?

Just fixed that guys, follow an example

Try {
            Remove-Folder -Path $CachePath
        }
        catch {
        Write-Log -Message "Error: $_" -Source $appDeployToolkitName
        Write-Log -Message "Error: $($_.InvocationInfo.PositionMessage)" -Source $appDeployToolkitName
        Exit-Script -ExitCode 9000
        }
1 Like

Happy to see you figured out your issue.

You might be interested in this too: How to Log built-in PowerShell commands (non-PSADT commands)