Romanitho/Winget-AutoUpdate

[Bug]: Symlink to logfile no longer gets created

s016aq opened this issue · 6 comments

The problem

I noticed that the symlink to the logfile is not being created during install any more (from version 1.18.0?)
Instead it's being created when the scheduled task is triggered (Winget-Upgrade.ps1)
But it is not created!
If I run Winget-Upgrade.ps1 from Powershell_ise (as SYSTEM) it works. But not with the Scheduled task.
If I remove ServiceUI.exe it works. So it has something to do with the script is spawned again with ServiceUI

What version of WAU has the issue?

from 1.18.0

What version of Windows are you using (ex. Windows 11 22H2)?

Windows 11 23H2

What version of winget are you using?

1.6.3482

Log information

No response

Additional information

No response

The existing logic expects to have full folder tree up to \Logs\WAU-update.log
if that folder structure is missing, then symlink is not created.
Was the folder present before WAU got installed?

# Check if Intune Management Extension Logs folder and WAU-install.log exists, make symlink
if ((Test-Path -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs" -ErrorAction SilentlyContinue) -and (Test-Path -Path ('{0}\logs\install.log' -f $WorkingDir) -ErrorAction SilentlyContinue) -and !(Test-Path -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ErrorAction SilentlyContinue)) {
Write-ToLog "-> Creating SymLink for log file (WAU-install) in Intune Management Extension log folder" "yellow"
$null = (New-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -ItemType SymbolicLink -Value ('{0}\logs\install.log' -f $WorkingDir) -Force -Confirm:$False -ErrorAction SilentlyContinue)
}

#Adds SymLink if Intune managed
$IntuneLogPath = "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs"
if ((Test-Path "$IntuneLogPath") -and !(Test-Path "$IntuneLogPath\WAU-updates.log")) {
Write-ToLog "Creating 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
}

Yes, full path present.
It's exactly as @s016aq describes it.

Maybe we should change the way we create the Symlink?
During the installation of WAU? Let's create an empty WAU-updates.log if it doesn't exist, and create the symlink at this moment. This way, context should be admin account OR system (without serviceui.exe) and should success.

This issue is stale because it has been open for 30 days with no activity.

This issue was closed because it has been inactive for 14 days since being marked as stale.