diff --git a/Windows_VDOT.ps1 b/Windows_VDOT.ps1 index 5150962..1423fcc 100644 --- a/Windows_VDOT.ps1 +++ b/Windows_VDOT.ps1 @@ -122,15 +122,19 @@ BEGIN { New-ItemProperty -Path $KeyPath -Name $LastRun -Value $LastRunValue | Out-Null } - + + $EventSources = @('VDOT', 'WindowsMediaPlayer', 'AppxPackages', 'ScheduledTasks', 'DefaultUserSettings', 'Autologgers', 'Services', 'NetworkOptimizations', 'LGPO', 'AdvancedOptimizations', 'DiskCleanup') If (-not([System.Diagnostics.EventLog]::SourceExists("Virtual Desktop Optimization"))) { # All VDOT main function Event ID's [1-9] - $EventSources = @('VDOT', 'WindowsMediaPlayer', 'AppxPackages', 'ScheduledTasks', 'DefaultUserSettings', 'Autologgers', 'Services', 'NetworkOptimizations', 'LGPO', 'AdvancedOptimizations', 'DiskCleanup') New-EventLog -Source $EventSources -LogName 'Virtual Desktop Optimization' Limit-EventLog -OverflowAction OverWriteAsNeeded -MaximumSize 64KB -LogName 'Virtual Desktop Optimization' Write-EventLog -LogName 'Virtual Desktop Optimization' -Source 'VDOT' -EntryType Information -EventId 1 -Message "Log Created" } + Else + { + New-EventLog -Source $EventSources -LogName 'Virtual Desktop Optimization' -ErrorAction SilentlyContinue + } Write-EventLog -LogName 'Virtual Desktop Optimization' -Source 'VDOT' -EntryType Information -EventId 1 -Message "Starting VDOT by user '$env:USERNAME', for VDOT build '$WindowsVersion', with the following options:`n$($PSBoundParameters | Out-String)" $StartTime = Get-Date