2022-03-14 13:55:02 +00:00
|
|
|
#Initialisation
|
|
|
|
|
|
|
|
function Start-Init {
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
#Config console output encoding
|
|
|
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
|
|
|
|
|
|
#Log Header
|
2022-03-26 08:22:49 +00:00
|
|
|
$Log = "`n##################################################`n# CHECK FOR APP UPDATES - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################"
|
2022-03-14 13:55:02 +00:00
|
|
|
$Log | Write-host
|
|
|
|
|
|
|
|
#Logs initialisation if admin
|
2022-06-10 08:26:41 +00:00
|
|
|
try {
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
$LogPath = "$WorkingDir\logs"
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
if (!(Test-Path $LogPath)) {
|
2022-03-14 13:55:02 +00:00
|
|
|
New-Item -ItemType Directory -Force -Path $LogPath
|
|
|
|
}
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
#Log file
|
|
|
|
$Script:LogFile = "$LogPath\updates.log"
|
|
|
|
$Log | out-file -filepath $LogFile -Append
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
}
|
|
|
|
#Logs initialisation if non-admin
|
2022-06-10 08:26:41 +00:00
|
|
|
catch {
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
$LogPath = "$env:USERPROFILE\Winget-AutoUpdate\logs"
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-06-10 08:26:41 +00:00
|
|
|
if (!(Test-Path $LogPath)) {
|
2022-03-14 13:55:02 +00:00
|
|
|
New-Item -ItemType Directory -Force -Path $LogPath
|
|
|
|
}
|
2022-04-13 16:50:06 +00:00
|
|
|
|
|
|
|
#Log file
|
2022-03-14 13:55:02 +00:00
|
|
|
$Script:LogFile = "$LogPath\updates.log"
|
|
|
|
$Log | out-file -filepath $LogFile -Append
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
}
|
2022-04-13 16:50:06 +00:00
|
|
|
|
2022-03-14 13:55:02 +00:00
|
|
|
}
|