App-V 5; Enable or disable all debug-logs

Been diving into the App-V 5 logs for a few days and got tired of enabling the debug and analytic log files. Made a small sample to enable them in a loop;

Enable all App-V 5 logs;

##Nicke Källén 2013-05-08
##Enable all logs
$appvlogs = Get-WinEvent -ListLog *AppV* -force | Where-Object {$_.IsEnabled -eq $false}
foreach ($logitem in $appvlogs) {
     write-host “Log enabled: ” $logitem.LogName
     $logitem.IsEnabled = $true
     $logitem.SaveChanges()
}
##Disable all logs
$appvlogs = Get-WinEvent -ListLog *AppV* -force | Where-Object {$_.IsEnabled -eq $true}
foreach ($logitem in $appvlogs) {
if (($logitem.LogName -ne "Microsoft-AppV-Client/Admin") -or ($logitem.LogName -ne "Microsoft-AppV-Client/Operational") -or ($logitem.LogName -ne "Microsoft-AppV-Client/Virtual Applications"))
{
     write-host “Log Disabled: ” $logitem.LogName
     $logitem.IsEnabled = $false
     $logitem.SaveChanges()
}}

No error handling is available, this is just a quick start to avoid loads of clicking.

(2013-05-05 – Added the Where-object to avoid getting errors…)

One thought on “App-V 5; Enable or disable all debug-logs

  1. Marco Reply

    You made a classic programming error:
    if (($logitem.LogName -ne "Microsoft-AppV-Client/Admin") -or ($logitem.LogName -ne "Microsoft-AppV-Client/Operational") -or ($logitem.LogName -ne "Microsoft-AppV-Client/Virtual Applications"))

    A good rule of thumb is never to use not equal with the OR operator. You can try the XOR option which make things very confusing or just plain programming structure methods:

    if (($logitem.LogName -eq "Microsoft-AppV-Client/Admin") -or ($logitem.LogName -eq "Microsoft-AppV-Client/Operational") -or ($logitem.LogName -eq "Microsoft-AppV-Client/Virtual Applications"))
    {
    write-host “Log Skipped: ” $logitem.LogName
    } else {
    write-host “Log Disabled: ” $logitem.LogName
    $logitem.IsEnabled = $false
    $logitem.SaveChanges()
    }

Leave a Reply

Your email address will not be published. Required fields are marked *