From 5fae7c7f651433eabb0ff4fcaf1cb152c0976f2f Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:29:57 +0200 Subject: [PATCH 1/2] Cleaning log from winget cmd --- Winget-AutoUpdate/functions/Update-App.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 7006b10..95927f1 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -31,11 +31,11 @@ Function Update-App ($app) { #Run Winget Upgrade command if ($ModsOverride) { Write-ToLog "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride" - & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append + & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Where-Object { $_ -notlike " *" } | Tee-Object -file $LogFile -Append } else { Write-ToLog "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" - & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append + & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Where-Object { $_ -notlike " *" } | Tee-Object -file $LogFile -Append } if ($ModsUpgrade) { @@ -62,11 +62,11 @@ Function Update-App ($app) { if ($ModsOverride) { Write-ToLog "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --force --override $ModsOverride" - & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --force --override $ModsOverride | Tee-Object -file $LogFile -Append + & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --force --override $ModsOverride | Where-Object { $_ -notlike " *" } | Tee-Object -file $LogFile -Append } else { Write-ToLog "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --force -h" - & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --force -h | Tee-Object -file $LogFile -Append + & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --force -h | Where-Object { $_ -notlike " *" } | Tee-Object -file $LogFile -Append } if ($ModsInstall) { From 0d7b11a4e50d2c9c67f9f161d12f4219263162e4 Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:39:33 +0200 Subject: [PATCH 2/2] CMTrace visibility --- Winget-AutoUpdate-Install.ps1 | 32 ++++++++++----------- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- Winget-AutoUpdate/functions/Write-ToLog.ps1 | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index c1993bc..f903c34 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -171,19 +171,19 @@ function Install-Prerequisites { Write-ToLog "-> Installing VC_redist.$OSArch.exe..." Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait Remove-Item $Installer -ErrorAction Ignore - Write-ToLog "-> MS Visual C++ 2015-2022 installed successfully`n" "Green" + Write-ToLog "-> MS Visual C++ 2015-2022 installed successfully`n " "Green" } catch { - Write-ToLog "-> MS Visual C++ 2015-2022 installation failed.`n" "Red" + Write-ToLog "-> MS Visual C++ 2015-2022 installation failed.`n " "Red" Start-Sleep 3 } } else { - Write-ToLog "-> MS Visual C++ 2015-2022 will not be installed.`n" "Magenta" + Write-ToLog "-> MS Visual C++ 2015-2022 will not be installed.`n " "Magenta" } } else { - Write-ToLog "-> Prerequisites checked. OK`n" "Green" + Write-ToLog "-> Prerequisites checked. OK`n " "Green" } } @@ -262,7 +262,7 @@ function Install-WinGet { Update-StoreApps } else { - Write-ToLog "-> WinGet is up to date: v$WinGetInstalledVersion`n" "Green" + Write-ToLog "-> WinGet is up to date: v$WinGetInstalledVersion`n " "Green" } } @@ -455,13 +455,13 @@ function Install-WingetAutoUpdate { Write-ToLog "Checking Mods Directory:" "Yellow" $Protected = Invoke-ModsProtect "$WingetUpdatePath\mods" if ($Protected -eq $True) { - Write-ToLog "-> The mods directory is now secured!`n" "Green" + Write-ToLog "-> The mods directory is now secured!`n " "Green" } elseif ($Protected -eq $False) { - Write-ToLog "-> The mods directory was already secured!`n" "Green" + Write-ToLog "-> The mods directory was already secured!`n " "Green" } else { - Write-ToLog "-> Error: The mods directory couldn't be verified as secured!`n" "Red" + Write-ToLog "-> Error: The mods directory couldn't be verified as secured!`n " "Red" } #Create Shortcuts @@ -530,15 +530,15 @@ function Uninstall-WingetAutoUpdate { Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null } - Write-ToLog "Uninstallation succeeded!`n" "Green" + Write-ToLog "Uninstallation succeeded!`n " "Green" Start-sleep 1 } else { - Write-ToLog "$InstallLocation not found! Uninstallation failed!`n" "Red" + Write-ToLog "$InstallLocation not found! Uninstallation failed!`n " "Red" } } catch { - Write-ToLog "Uninstallation failed! Run as admin ?`n" "Red" + Write-ToLog "Uninstallation failed! Run as admin ?`n " "Red" Start-sleep 1 } } @@ -607,7 +607,7 @@ $Script:ProgressPreference = 'SilentlyContinue' #Set install log file $Script:LogFile = "$WingetUpdatePath\logs\WAU-Installer.log" -Write-Host "`n" +Write-Host "`n " Write-Host "`t 888 888 d8888 888 888" -ForegroundColor Magenta Write-Host "`t 888 o 888 d88888 888 888" -ForegroundColor Magenta Write-Host "`t 888 d8b 888 d88P888 888 888" -ForegroundColor Magenta @@ -615,10 +615,10 @@ Write-Host "`t 888 d888b 888 d88P 888 888 888" -ForegroundColor Write-Host "`t 888d88888b888 d88P 888 888 888" -ForegroundColor Magenta Write-Host "`t 88888P Y88888 d88P 888 888 888" -ForegroundColor Cyan Write-Host "`t 8888P Y8888 d88P 888 888 888" -ForegroundColor Magenta -Write-Host "`t 888P Y888 d88P 888 Y8888888P`n" -ForegroundColor Magenta -Write-Host "`t Winget-AutoUpdate $WAUVersion`n" -ForegroundColor Cyan -Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta -Write-Host "`t________________________________________________________`n`n" +Write-Host "`t 888P Y888 d88P 888 Y8888888P`n " -ForegroundColor Magenta +Write-Host "`t Winget-AutoUpdate $WAUVersion`n " -ForegroundColor Cyan +Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n " -ForegroundColor Magenta +Write-Host "`t________________________________________________________`n `n " if (!$Uninstall) { Write-ToLog "Installing WAU to $WingetUpdatePath\" diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 5d0dbab..7c21a32 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -351,7 +351,7 @@ if (Test-Network) { #Adds SymLink if Intune managed $IntuneLogPath = "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs" if ((Test-Path "$IntuneLogPath") -and !(Test-Path "$IntuneLogPath\WAU-updates.log")) { - Write-ToLog "`nCreating SymLink for log file (WAU-updates) in Intune Management Extension log folder" "Yellow" + Write-ToLog " `nCreating SymLink for log file (WAU-updates) in Intune Management Extension log folder" "Yellow" New-Item -Path "$IntuneLogPath\WAU-updates.log" -ItemType SymbolicLink -Value $LogFile -Force -ErrorAction SilentlyContinue | Out-Null } diff --git a/Winget-AutoUpdate/functions/Write-ToLog.ps1 b/Winget-AutoUpdate/functions/Write-ToLog.ps1 index 5ac4e61..976a639 100644 --- a/Winget-AutoUpdate/functions/Write-ToLog.ps1 +++ b/Winget-AutoUpdate/functions/Write-ToLog.ps1 @@ -26,7 +26,7 @@ function Write-ToLog { #If header requested if ($IsHeader) { - $Log = "`n##################################################`n# $LogMsg - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################" + $Log = " `n##################################################`n# $LogMsg - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################" } else { $Log = "$(Get-Date -UFormat "%T") - $LogMsg"