Minor format changes
parent
1320e7d356
commit
6c118323f9
|
@ -92,27 +92,56 @@
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[Alias('S')] [Switch] $Silent = $false,
|
[Alias('S')]
|
||||||
[Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
|
[Switch]
|
||||||
[Alias('List')] [String] $ListPath,
|
$Silent = $false,
|
||||||
[Alias('Mods')] [String] $ModsPath,
|
[Alias('Path')]
|
||||||
[Alias('AzureBlobURL')] [String] $AzureBlobSASURL,
|
[String]
|
||||||
[Switch] $DoNotUpdate = $false,
|
$WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
|
||||||
[Switch] $DisableWAUAutoUpdate = $false,
|
[Alias('List')]
|
||||||
[Switch] $RunOnMetered = $false,
|
[String]
|
||||||
[Switch] $Uninstall = $false,
|
$ListPath,
|
||||||
[Switch] $NoClean = $false,
|
[Alias('Mods')]
|
||||||
[Switch] $DesktopShortcut = $false,
|
[String]
|
||||||
[Switch] $StartMenuShortcut = $false,
|
$ModsPath,
|
||||||
[Switch] $UseWhiteList = $false,
|
[Alias('AzureBlobURL')]
|
||||||
[ValidateSet('Full', 'SuccessOnly', 'None')] [String] $NotificationLevel = 'Full',
|
[String]
|
||||||
[Switch] $UpdatesAtLogon = $false,
|
$AzureBlobSASURL,
|
||||||
[ValidateSet('Daily', 'BiDaily', 'Weekly', 'BiWeekly', 'Monthly', 'Never')] [String] $UpdatesInterval = 'Daily',
|
[Switch]
|
||||||
[DateTime] $UpdatesAtTime = ('06am'),
|
$DoNotUpdate = $false,
|
||||||
[Switch] $BypassListForUsers = $false,
|
[Switch]
|
||||||
[Switch] $InstallUserContext = $false,
|
$DisableWAUAutoUpdate = $false,
|
||||||
[ValidateRange(0, 99)] [int] $MaxLogFiles = 3,
|
[Switch]
|
||||||
[long] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
|
$RunOnMetered = $false,
|
||||||
|
[Switch]
|
||||||
|
$Uninstall = $false,
|
||||||
|
[Switch]
|
||||||
|
$NoClean = $false,
|
||||||
|
[Switch]
|
||||||
|
$DesktopShortcut = $false,
|
||||||
|
[Switch]
|
||||||
|
$StartMenuShortcut = $false,
|
||||||
|
[Switch]
|
||||||
|
$UseWhiteList = $false,
|
||||||
|
[ValidateSet('Full', 'SuccessOnly', 'None')]
|
||||||
|
[String]
|
||||||
|
$NotificationLevel = 'Full',
|
||||||
|
[Switch]
|
||||||
|
$UpdatesAtLogon = $false,
|
||||||
|
[ValidateSet('Daily', 'BiDaily', 'Weekly', 'BiWeekly', 'Monthly', 'Never')]
|
||||||
|
[String]
|
||||||
|
$UpdatesInterval = 'Daily',
|
||||||
|
[DateTime]
|
||||||
|
$UpdatesAtTime = ('06am'),
|
||||||
|
[Switch]
|
||||||
|
$BypassListForUsers = $false,
|
||||||
|
[Switch]
|
||||||
|
$InstallUserContext = $false,
|
||||||
|
[ValidateRange(0, 99)]
|
||||||
|
[int]
|
||||||
|
$MaxLogFiles = 3,
|
||||||
|
[long]
|
||||||
|
$MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,11 +232,11 @@ function Install-WinGet
|
||||||
}
|
}
|
||||||
|
|
||||||
#Current: v1.5.2201 = 1.20.2201.0 = 2023.808.2243.0
|
#Current: v1.5.2201 = 1.20.2201.0 = 2023.808.2243.0
|
||||||
If ([Version]$TestWinGet.Version -ge '2023.808.2243.0')
|
if ([Version]$TestWinGet.Version -ge '2023.808.2243.0')
|
||||||
{
|
{
|
||||||
Write-Host -Object 'Winget is Installed' -ForegroundColor Green
|
Write-Host -Object 'Winget is Installed' -ForegroundColor Green
|
||||||
}
|
}
|
||||||
Else
|
else
|
||||||
{
|
{
|
||||||
Write-Host -Object '-> Winget is not installed:'
|
Write-Host -Object '-> Winget is not installed:'
|
||||||
|
|
||||||
|
@ -646,13 +675,9 @@ function Add-Shortcut
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
$Target,
|
$Target,
|
||||||
|
|
||||||
$Shortcut,
|
$Shortcut,
|
||||||
|
|
||||||
$Arguments,
|
$Arguments,
|
||||||
|
|
||||||
$Icon,
|
$Icon,
|
||||||
|
|
||||||
$Description
|
$Description
|
||||||
)
|
)
|
||||||
$WScriptShell = New-Object -ComObject WScript.Shell
|
$WScriptShell = New-Object -ComObject WScript.Shell
|
||||||
|
@ -678,7 +703,7 @@ if ("$env:PROCESSOR_ARCHITEW6432" -ne 'ARM64')
|
||||||
if (Test-Path -Path "$($env:windir)\SysNative\WindowsPowerShell\v1.0\powershell.exe")
|
if (Test-Path -Path "$($env:windir)\SysNative\WindowsPowerShell\v1.0\powershell.exe")
|
||||||
{
|
{
|
||||||
Start-Process -FilePath "$($env:windir)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -Wait -NoNewWindow -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command $($MyInvocation.line)"
|
Start-Process -FilePath "$($env:windir)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -Wait -NoNewWindow -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command $($MyInvocation.line)"
|
||||||
Exit $lastexitcode
|
exit $lastexitcode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,17 @@
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[Switch] $Logs = $False,
|
[Switch]
|
||||||
[Switch] $Help = $False
|
$Logs = $False,
|
||||||
|
[Switch]
|
||||||
|
$Help = $False
|
||||||
)
|
)
|
||||||
|
|
||||||
function Test-WAUisRunning
|
function Test-WAUisRunning
|
||||||
{
|
{
|
||||||
If (((Get-ScheduledTask -TaskName 'Winget-AutoUpdate' -ErrorAction SilentlyContinue).State -eq 'Running') -or ((Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue).State -eq 'Running'))
|
if (((Get-ScheduledTask -TaskName 'Winget-AutoUpdate' -ErrorAction SilentlyContinue).State -eq 'Running') -or ((Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue).State -eq 'Running'))
|
||||||
{
|
{
|
||||||
Return $True
|
return $True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ else
|
||||||
$MessageType = 'info'
|
$MessageType = 'info'
|
||||||
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
|
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
|
||||||
# Sleep until the task is done
|
# Sleep until the task is done
|
||||||
While (Test-WAUisRunning)
|
while (Test-WAUisRunning)
|
||||||
{
|
{
|
||||||
Start-Sleep -Seconds 3
|
Start-Sleep -Seconds 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
#>
|
#>
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[Switch] $NoClean = $false
|
[Switch]
|
||||||
|
$NoClean = $false
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Host -Object "`n"
|
Write-Host -Object "`n"
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
$Script:WorkingDir = $PSScriptRoot
|
$Script:WorkingDir = $PSScriptRoot
|
||||||
|
|
||||||
# Get Functions
|
# Get Functions
|
||||||
Get-ChildItem -Path "$WorkingDir\functions" | ForEach-Object { . $_.FullName }
|
Get-ChildItem -Path "$WorkingDir\functions" | ForEach-Object {
|
||||||
|
. $_.FullName
|
||||||
|
}
|
||||||
|
|
||||||
<# MAIN #>
|
<# MAIN #>
|
||||||
|
|
||||||
|
@ -18,54 +20,65 @@ Start-Init
|
||||||
$Script:WAUConfig = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate')
|
$Script:WAUConfig = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate')
|
||||||
|
|
||||||
#Log running context and more...
|
#Log running context and more...
|
||||||
if ($IsSystem) {
|
if ($IsSystem)
|
||||||
|
{
|
||||||
Write-ToLog 'Running in System context'
|
Write-ToLog 'Running in System context'
|
||||||
|
|
||||||
#Get and set Domain/Local Policies (GPO)
|
#Get and set Domain/Local Policies (GPO)
|
||||||
$ActivateGPOManagement, $ChangedSettings = Get-Policies
|
$ActivateGPOManagement, $ChangedSettings = Get-Policies
|
||||||
if ($ActivateGPOManagement) {
|
if ($ActivateGPOManagement)
|
||||||
|
{
|
||||||
Write-ToLog 'Activated WAU GPO Management detected, comparing...'
|
Write-ToLog 'Activated WAU GPO Management detected, comparing...'
|
||||||
if ($null -ne $ChangedSettings -and $ChangedSettings -ne 0) {
|
if ($null -ne $ChangedSettings -and $ChangedSettings -ne 0)
|
||||||
|
{
|
||||||
Write-ToLog 'Changed settings detected and applied' 'Yellow'
|
Write-ToLog 'Changed settings detected and applied' 'Yellow'
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog 'No Changed settings detected' 'Yellow'
|
Write-ToLog 'No Changed settings detected' 'Yellow'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Maximum number of log files to keep. Default is 3. Setting MaxLogFiles to 0 will keep all log files.
|
# Maximum number of log files to keep. Default is 3. Setting MaxLogFiles to 0 will keep all log files.
|
||||||
$MaxLogFiles = $WAUConfig.WAU_MaxLogFiles
|
$MaxLogFiles = $WAUConfig.WAU_MaxLogFiles
|
||||||
if ($null -eq $MaxLogFiles) {
|
if ($null -eq $MaxLogFiles)
|
||||||
|
{
|
||||||
[int]$MaxLogFiles = 3
|
[int]$MaxLogFiles = 3
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
[int]$MaxLogFiles = $MaxLogFiles
|
[int]$MaxLogFiles = $MaxLogFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
# Maximum size of log file.
|
# Maximum size of log file.
|
||||||
$MaxLogSize = $WAUConfig.WAU_MaxLogSize
|
$MaxLogSize = $WAUConfig.WAU_MaxLogSize
|
||||||
if (!$MaxLogSize) {
|
if (!$MaxLogSize)
|
||||||
|
{
|
||||||
[long]$MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
|
[long]$MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
[long]$MaxLogSize = $MaxLogSize
|
[long]$MaxLogSize = $MaxLogSize
|
||||||
}
|
}
|
||||||
|
|
||||||
#LogRotation if System
|
#LogRotation if System
|
||||||
$LogRotate = Invoke-LogRotation $LogFile $MaxLogFiles $MaxLogSize
|
$LogRotate = Invoke-LogRotation $LogFile $MaxLogFiles $MaxLogSize
|
||||||
if ($LogRotate -eq $False) {
|
if ($LogRotate -eq $False)
|
||||||
|
{
|
||||||
Write-ToLog 'An Exception occured during Log Rotation...'
|
Write-ToLog 'An Exception occured during Log Rotation...'
|
||||||
}
|
}
|
||||||
|
|
||||||
#Run post update actions if necessary if run as System
|
#Run post update actions if necessary if run as System
|
||||||
if (!($WAUConfig.WAU_PostUpdateActions -eq 0)) {
|
if (!($WAUConfig.WAU_PostUpdateActions -eq 0))
|
||||||
|
{
|
||||||
Invoke-PostUpdateActions
|
Invoke-PostUpdateActions
|
||||||
}
|
}
|
||||||
#Run Scope Machine funtion if run as System
|
#Run Scope Machine funtion if run as System
|
||||||
$SettingsPath = "$Env:windir\system32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\defaultState\settings.json"
|
$SettingsPath = "$Env:windir\system32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\defaultState\settings.json"
|
||||||
Add-ScopeMachine $SettingsPath
|
Add-ScopeMachine $SettingsPath
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog 'Running in User context'
|
Write-ToLog 'Running in User context'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,158 +87,197 @@ $LocaleDisplayName = Get-NotifLocale
|
||||||
Write-ToLog "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification Language: $LocaleDisplayName" 'Cyan'
|
Write-ToLog "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification Language: $LocaleDisplayName" 'Cyan'
|
||||||
|
|
||||||
#Check network connectivity
|
#Check network connectivity
|
||||||
if (Test-Network) {
|
if (Test-Network)
|
||||||
|
{
|
||||||
#Check if Winget is installed and get Winget cmd
|
#Check if Winget is installed and get Winget cmd
|
||||||
$TestWinget = Get-WingetCmd
|
$TestWinget = Get-WingetCmd
|
||||||
|
|
||||||
if ($TestWinget) {
|
if ($TestWinget)
|
||||||
|
{
|
||||||
#Get Current Version
|
#Get Current Version
|
||||||
$WAUCurrentVersion = $WAUConfig.DisplayVersion
|
$WAUCurrentVersion = $WAUConfig.DisplayVersion
|
||||||
Write-ToLog "WAU current version: $WAUCurrentVersion"
|
Write-ToLog "WAU current version: $WAUCurrentVersion"
|
||||||
if ($IsSystem) {
|
if ($IsSystem)
|
||||||
|
{
|
||||||
#Check if WAU update feature is enabled or not if run as System
|
#Check if WAU update feature is enabled or not if run as System
|
||||||
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
|
||||||
#If yes then check WAU update if run as System
|
#If yes then check WAU update if run as System
|
||||||
if ($WAUDisableAutoUpdate -eq 1) {
|
if ($WAUDisableAutoUpdate -eq 1)
|
||||||
|
{
|
||||||
Write-ToLog 'WAU AutoUpdate is Disabled.' 'Gray'
|
Write-ToLog 'WAU AutoUpdate is Disabled.' 'Gray'
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog 'WAU AutoUpdate is Enabled.' 'Green'
|
Write-ToLog 'WAU AutoUpdate is Enabled.' 'Green'
|
||||||
#Get Available Version
|
#Get Available Version
|
||||||
$Script:WAUAvailableVersion = Get-WAUAvailableVersion
|
$Script:WAUAvailableVersion = Get-WAUAvailableVersion
|
||||||
#Compare
|
#Compare
|
||||||
if ([version]$WAUAvailableVersion.Replace('-', '.') -ne [version]$WAUCurrentVersion.Replace('-', '.')) {
|
if ([version]$WAUAvailableVersion.Replace('-', '.') -ne [version]$WAUCurrentVersion.Replace('-', '.'))
|
||||||
|
{
|
||||||
#If new version is available, update it
|
#If new version is available, update it
|
||||||
Write-ToLog "WAU Available version: $WAUAvailableVersion" 'Yellow'
|
Write-ToLog "WAU Available version: $WAUAvailableVersion" 'Yellow'
|
||||||
Update-WAU
|
Update-WAU
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog 'WAU is up to date.' 'Green'
|
Write-ToLog 'WAU is up to date.' 'Green'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Delete previous list_/winget_error (if they exist) if run as System
|
#Delete previous list_/winget_error (if they exist) if run as System
|
||||||
if (Test-Path -Path "$WorkingDir\logs\error.txt") {
|
if (Test-Path -Path "$WorkingDir\logs\error.txt")
|
||||||
|
{
|
||||||
Remove-Item -Path "$WorkingDir\logs\error.txt" -Force
|
Remove-Item -Path "$WorkingDir\logs\error.txt" -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get External ListPath if run as System
|
#Get External ListPath if run as System
|
||||||
if ($WAUConfig.WAU_ListPath) {
|
if ($WAUConfig.WAU_ListPath)
|
||||||
|
{
|
||||||
$ListPathClean = $($WAUConfig.WAU_ListPath.TrimEnd(' ', '\', '/'))
|
$ListPathClean = $($WAUConfig.WAU_ListPath.TrimEnd(' ', '\', '/'))
|
||||||
Write-ToLog "WAU uses External Lists from: $ListPathClean"
|
Write-ToLog "WAU uses External Lists from: $ListPathClean"
|
||||||
if ($ListPathClean -ne 'GPO') {
|
if ($ListPathClean -ne 'GPO')
|
||||||
|
{
|
||||||
$NewList = Test-ListPath $ListPathClean $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation.TrimEnd(' ', '\')
|
$NewList = Test-ListPath $ListPathClean $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation.TrimEnd(' ', '\')
|
||||||
if ($ReachNoPath) {
|
if ($ReachNoPath)
|
||||||
|
{
|
||||||
Write-ToLog "Couldn't reach/find/compare/copy from $ListPathClean..." 'Red'
|
Write-ToLog "Couldn't reach/find/compare/copy from $ListPathClean..." 'Red'
|
||||||
if ($ListPathClean -notlike 'http*') {
|
if ($ListPathClean -notlike 'http*')
|
||||||
if (Test-Path -Path "$ListPathClean" -PathType Leaf) {
|
{
|
||||||
|
if (Test-Path -Path "$ListPathClean" -PathType Leaf)
|
||||||
|
{
|
||||||
Write-ToLog 'PATH must end with a Directory, not a File...' 'Red'
|
Write-ToLog 'PATH must end with a Directory, not a File...' 'Red'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if ($ListPathClean -match '_apps.txt') {
|
{
|
||||||
|
if ($ListPathClean -match '_apps.txt')
|
||||||
|
{
|
||||||
Write-ToLog 'PATH must end with a Directory, not a File...' 'Red'
|
Write-ToLog 'PATH must end with a Directory, not a File...' 'Red'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$Script:ReachNoPath = $False
|
$Script:ReachNoPath = $False
|
||||||
}
|
}
|
||||||
if ($NewList) {
|
if ($NewList)
|
||||||
|
{
|
||||||
Write-ToLog "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(' ', '\'))" 'Yellow'
|
Write-ToLog "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(' ', '\'))" 'Yellow'
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if ($WAUConfig.WAU_UseWhiteList -and (Test-Path -Path "$WorkingDir\included_apps.txt")) {
|
{
|
||||||
|
if ($WAUConfig.WAU_UseWhiteList -and (Test-Path -Path "$WorkingDir\included_apps.txt"))
|
||||||
|
{
|
||||||
Write-ToLog 'List (white) is up to date.' 'Green'
|
Write-ToLog 'List (white) is up to date.' 'Green'
|
||||||
}
|
}
|
||||||
elseif (!$WAUConfig.WAU_UseWhiteList -and (Test-Path -Path "$WorkingDir\excluded_apps.txt")) {
|
elseif (!$WAUConfig.WAU_UseWhiteList -and (Test-Path -Path "$WorkingDir\excluded_apps.txt"))
|
||||||
|
{
|
||||||
Write-ToLog 'List (black) is up to date.' 'Green'
|
Write-ToLog 'List (black) is up to date.' 'Green'
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog "Critical: White/Black List doesn't exist, exiting..." 'Red'
|
Write-ToLog "Critical: White/Black List doesn't exist, exiting..." 'Red'
|
||||||
New-Item -Path "$WorkingDir\logs\error.txt" -Value "White/Black List doesn't exist" -Force
|
New-Item -Path "$WorkingDir\logs\error.txt" -Value "White/Black List doesn't exist" -Force
|
||||||
Exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get External ModsPath if run as System
|
#Get External ModsPath if run as System
|
||||||
if ($WAUConfig.WAU_ModsPath) {
|
if ($WAUConfig.WAU_ModsPath)
|
||||||
|
{
|
||||||
$ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(' ', '\', '/'))
|
$ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(' ', '\', '/'))
|
||||||
Write-ToLog "WAU uses External Mods from: $ModsPathClean"
|
Write-ToLog "WAU uses External Mods from: $ModsPathClean"
|
||||||
if ($WAUConfig.WAU_AzureBlobSASURL) {
|
if ($WAUConfig.WAU_AzureBlobSASURL)
|
||||||
|
{
|
||||||
$NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(' ', '\') $WAUConfig.WAU_AzureBlobSASURL.TrimEnd(' ')
|
$NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(' ', '\') $WAUConfig.WAU_AzureBlobSASURL.TrimEnd(' ')
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(' ', '\')
|
$NewMods, $DeletedMods = Test-ModsPath $ModsPathClean $WAUConfig.InstallLocation.TrimEnd(' ', '\')
|
||||||
}
|
}
|
||||||
if ($ReachNoPath) {
|
if ($ReachNoPath)
|
||||||
|
{
|
||||||
Write-ToLog "Couldn't reach/find/compare/copy from $ModsPathClean..." 'Red'
|
Write-ToLog "Couldn't reach/find/compare/copy from $ModsPathClean..." 'Red'
|
||||||
$Script:ReachNoPath = $False
|
$Script:ReachNoPath = $False
|
||||||
}
|
}
|
||||||
if ($NewMods -gt 0) {
|
if ($NewMods -gt 0)
|
||||||
|
{
|
||||||
Write-ToLog "$NewMods newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(' ', '\'))\mods" 'Yellow'
|
Write-ToLog "$NewMods newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(' ', '\'))\mods" 'Yellow'
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if (Test-Path -Path "$WorkingDir\mods\*.ps1") {
|
{
|
||||||
|
if (Test-Path -Path "$WorkingDir\mods\*.ps1")
|
||||||
|
{
|
||||||
Write-ToLog 'Mods are up to date.' 'Green'
|
Write-ToLog 'Mods are up to date.' 'Green'
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog 'No Mods are implemented...' 'Yellow'
|
Write-ToLog 'No Mods are implemented...' 'Yellow'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($DeletedMods -gt 0) {
|
if ($DeletedMods -gt 0)
|
||||||
|
{
|
||||||
Write-ToLog "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation.TrimEnd(' ', '\'))\mods" 'Red'
|
Write-ToLog "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation.TrimEnd(' ', '\'))\mods" 'Red'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Test if _WAU-mods.ps1 exist: Mods for WAU (if Network is active/any Winget is installed/running as SYSTEM)
|
#Test if _WAU-mods.ps1 exist: Mods for WAU (if Network is active/any Winget is installed/running as SYSTEM)
|
||||||
$Mods = "$WorkingDir\mods"
|
$Mods = "$WorkingDir\mods"
|
||||||
if (Test-Path -Path "$Mods\_WAU-mods.ps1") {
|
if (Test-Path -Path "$Mods\_WAU-mods.ps1")
|
||||||
|
{
|
||||||
Write-ToLog 'Running Mods for WAU...' 'Yellow'
|
Write-ToLog 'Running Mods for WAU...' 'Yellow'
|
||||||
& "$Mods\_WAU-mods.ps1"
|
& "$Mods\_WAU-mods.ps1"
|
||||||
$ModsExitCode = $LASTEXITCODE
|
$ModsExitCode = $LASTEXITCODE
|
||||||
#If _WAU-mods.ps1 has ExitCode 1 - Re-run WAU
|
#If _WAU-mods.ps1 has ExitCode 1 - Re-run WAU
|
||||||
if ($ModsExitCode -eq 1) {
|
if ($ModsExitCode -eq 1)
|
||||||
|
{
|
||||||
Write-ToLog 'Re-run WAU'
|
Write-ToLog 'Re-run WAU'
|
||||||
Start-Process -FilePath powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade.ps1`""
|
Start-Process -FilePath powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade.ps1`""
|
||||||
Exit
|
exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($($WAUConfig.WAU_ListPath) -eq 'GPO') {
|
if ($($WAUConfig.WAU_ListPath) -eq 'GPO')
|
||||||
|
{
|
||||||
$Script:GPOList = $True
|
$Script:GPOList = $True
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get White or Black list
|
#Get White or Black list
|
||||||
if ($WAUConfig.WAU_UseWhiteList -eq 1) {
|
if ($WAUConfig.WAU_UseWhiteList -eq 1)
|
||||||
|
{
|
||||||
Write-ToLog 'WAU uses White List config'
|
Write-ToLog 'WAU uses White List config'
|
||||||
$toUpdate = Get-IncludedApps
|
$toUpdate = Get-IncludedApps
|
||||||
$UseWhiteList = $true
|
$UseWhiteList = $true
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog 'WAU uses Black List config'
|
Write-ToLog 'WAU uses Black List config'
|
||||||
$toSkip = Get-ExcludedApps
|
$toSkip = Get-ExcludedApps
|
||||||
}
|
}
|
||||||
|
|
||||||
#Fix and count the array if GPO List as ERROR handling!
|
#Fix and count the array if GPO List as ERROR handling!
|
||||||
if ($GPOList) {
|
if ($GPOList)
|
||||||
if ($UseWhiteList) {
|
{
|
||||||
|
if ($UseWhiteList)
|
||||||
|
{
|
||||||
$WhiteList = $toUpdate.GetUpperBound(0)
|
$WhiteList = $toUpdate.GetUpperBound(0)
|
||||||
if ($null -eq $WhiteList) {
|
if ($null -eq $WhiteList)
|
||||||
|
{
|
||||||
Write-ToLog "Critical: Whitelist doesn't exist in GPO, exiting..." 'Red'
|
Write-ToLog "Critical: Whitelist doesn't exist in GPO, exiting..." 'Red'
|
||||||
New-Item -Path "$WorkingDir\logs\error.txt" -Value "Whitelist doesn't exist in GPO" -Force
|
New-Item -Path "$WorkingDir\logs\error.txt" -Value "Whitelist doesn't exist in GPO" -Force
|
||||||
Exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
$toUpdate = $toUpdate.Data
|
$toUpdate = $toUpdate.Data
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$BlackList = $toSkip.GetUpperBound(0)
|
$BlackList = $toSkip.GetUpperBound(0)
|
||||||
if ($null -eq $BlackList) {
|
if ($null -eq $BlackList)
|
||||||
|
{
|
||||||
Write-ToLog "Critical: Blacklist doesn't exist in GPO, exiting..." 'Red'
|
Write-ToLog "Critical: Blacklist doesn't exist in GPO, exiting..." 'Red'
|
||||||
New-Item -Path "$WorkingDir\logs\error.txt" -Value "Blacklist doesn't exist in GPO" -Force
|
New-Item -Path "$WorkingDir\logs\error.txt" -Value "Blacklist doesn't exist in GPO" -Force
|
||||||
Exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
$toSkip = $toSkip.Data
|
$toSkip = $toSkip.Data
|
||||||
}
|
}
|
||||||
|
@ -236,15 +288,18 @@ if (Test-Network) {
|
||||||
$outdated = Get-WingetOutdatedApps
|
$outdated = Get-WingetOutdatedApps
|
||||||
|
|
||||||
#If something unusual happened
|
#If something unusual happened
|
||||||
if ($outdated -like 'An unusual*') {
|
if ($outdated -like 'An unusual*')
|
||||||
|
{
|
||||||
Write-ToLog "$outdated" 'cyan'
|
Write-ToLog "$outdated" 'cyan'
|
||||||
$outdated = $False
|
$outdated = $False
|
||||||
}
|
}
|
||||||
|
|
||||||
#Run only if $outdated is populated!
|
#Run only if $outdated is populated!
|
||||||
if ($outdated) {
|
if ($outdated)
|
||||||
|
{
|
||||||
#Log list of app to update
|
#Log list of app to update
|
||||||
foreach ($app in $outdated) {
|
foreach ($app in $outdated)
|
||||||
|
{
|
||||||
#List available updates
|
#List available updates
|
||||||
$Log = "-> Available update : $($app.Name). Current version : $($app.Version). Available version : $($app.AvailableVersion)."
|
$Log = "-> Available update : $($app.Name). Current version : $($app.Version). Available version : $($app.AvailableVersion)."
|
||||||
$Log | Write-host
|
$Log | Write-host
|
||||||
|
@ -255,67 +310,84 @@ if (Test-Network) {
|
||||||
$Script:InstallOK = 0
|
$Script:InstallOK = 0
|
||||||
|
|
||||||
#Trick under user context when -BypassListForUsers is used
|
#Trick under user context when -BypassListForUsers is used
|
||||||
if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq 1) {
|
if ($IsSystem -eq $false -and $WAUConfig.WAU_BypassListForUsers -eq 1)
|
||||||
|
{
|
||||||
Write-ToLog 'Bypass system list in user context is Enabled.'
|
Write-ToLog 'Bypass system list in user context is Enabled.'
|
||||||
$UseWhiteList = $false
|
$UseWhiteList = $false
|
||||||
$toSkip = $null
|
$toSkip = $null
|
||||||
}
|
}
|
||||||
|
|
||||||
#If White List
|
#If White List
|
||||||
if ($UseWhiteList) {
|
if ($UseWhiteList)
|
||||||
|
{
|
||||||
#For each app, notify and update
|
#For each app, notify and update
|
||||||
foreach ($app in $outdated) {
|
foreach ($app in $outdated)
|
||||||
if (($toUpdate -contains $app.Id) -and $($app.Version) -ne 'Unknown') {
|
{
|
||||||
|
if (($toUpdate -contains $app.Id) -and $($app.Version) -ne 'Unknown')
|
||||||
|
{
|
||||||
Update-App $app
|
Update-App $app
|
||||||
}
|
}
|
||||||
#if current app version is unknown
|
#if current app version is unknown
|
||||||
elseif ($($app.Version) -eq 'Unknown') {
|
elseif ($($app.Version) -eq 'Unknown')
|
||||||
|
{
|
||||||
Write-ToLog "$($app.Name) : Skipped upgrade because current version is 'Unknown'" 'Gray'
|
Write-ToLog "$($app.Name) : Skipped upgrade because current version is 'Unknown'" 'Gray'
|
||||||
}
|
}
|
||||||
#if app is in "excluded list"
|
#if app is in "excluded list"
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog "$($app.Name) : Skipped upgrade because it is not in the included app list" 'Gray'
|
Write-ToLog "$($app.Name) : Skipped upgrade because it is not in the included app list" 'Gray'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#If Black List or default
|
#If Black List or default
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
#For each app, notify and update
|
#For each app, notify and update
|
||||||
foreach ($app in $outdated) {
|
foreach ($app in $outdated)
|
||||||
if (-not ($toSkip -contains $app.Id) -and $($app.Version) -ne 'Unknown') {
|
{
|
||||||
|
if (-not ($toSkip -contains $app.Id) -and $($app.Version) -ne 'Unknown')
|
||||||
|
{
|
||||||
Update-App $app
|
Update-App $app
|
||||||
}
|
}
|
||||||
#if current app version is unknown
|
#if current app version is unknown
|
||||||
elseif ($($app.Version) -eq 'Unknown') {
|
elseif ($($app.Version) -eq 'Unknown')
|
||||||
|
{
|
||||||
Write-ToLog "$($app.Name) : Skipped upgrade because current version is 'Unknown'" 'Gray'
|
Write-ToLog "$($app.Name) : Skipped upgrade because current version is 'Unknown'" 'Gray'
|
||||||
}
|
}
|
||||||
#if app is in "excluded list"
|
#if app is in "excluded list"
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog "$($app.Name) : Skipped upgrade because it is in the excluded app list" 'Gray'
|
Write-ToLog "$($app.Name) : Skipped upgrade because it is in the excluded app list" 'Gray'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($InstallOK -gt 0) {
|
if ($InstallOK -gt 0)
|
||||||
|
{
|
||||||
Write-ToLog "$InstallOK apps updated ! No more update." 'Green'
|
Write-ToLog "$InstallOK apps updated ! No more update." 'Green'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($InstallOK -eq 0 -or !$InstallOK) {
|
if ($InstallOK -eq 0 -or !$InstallOK)
|
||||||
|
{
|
||||||
Write-ToLog 'No new update.' 'Green'
|
Write-ToLog 'No new update.' 'Green'
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check if any user is logged on if System and run User task (if installed)
|
#Check if any user is logged on if System and run User task (if installed)
|
||||||
if ($IsSystem) {
|
if ($IsSystem)
|
||||||
|
{
|
||||||
#User check routine from: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status
|
#User check routine from: https://stackoverflow.com/questions/23219718/powershell-script-to-see-currently-logged-in-users-domain-and-machine-status
|
||||||
$explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
|
$explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
|
||||||
If ($explorerprocesses.Count -eq 0) {
|
if ($explorerprocesses.Count -eq 0)
|
||||||
|
{
|
||||||
Write-ToLog 'No explorer process found / Nobody interactively logged on...'
|
Write-ToLog 'No explorer process found / Nobody interactively logged on...'
|
||||||
}
|
}
|
||||||
Else {
|
else
|
||||||
|
{
|
||||||
#Run WAU in user context if the user task exist
|
#Run WAU in user context if the user task exist
|
||||||
$UserScheduledTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
|
$UserScheduledTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
|
||||||
if ($UserScheduledTask) {
|
if ($UserScheduledTask)
|
||||||
|
{
|
||||||
|
|
||||||
#Get Winget system apps to excape them befor running user context
|
#Get Winget system apps to excape them befor running user context
|
||||||
Write-ToLog 'User logged on, get a list of installed Winget apps in System context...'
|
Write-ToLog 'User logged on, get a list of installed Winget apps in System context...'
|
||||||
|
@ -324,19 +396,21 @@ if (Test-Network) {
|
||||||
#Run user context scheduled task
|
#Run user context scheduled task
|
||||||
Write-ToLog 'Starting WAU in User context'
|
Write-ToLog 'Starting WAU in User context'
|
||||||
Start-ScheduledTask -TaskName $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
|
Start-ScheduledTask -TaskName $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
|
||||||
Exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
elseif (!$UserScheduledTask) {
|
elseif (!$UserScheduledTask)
|
||||||
|
{
|
||||||
Write-ToLog 'User context execution not installed...'
|
Write-ToLog 'User context execution not installed...'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
Write-ToLog 'Critical: Winget not installed or detected, exiting...' 'red'
|
Write-ToLog 'Critical: Winget not installed or detected, exiting...' 'red'
|
||||||
New-Item -Path "$WorkingDir\logs\error.txt" -Value 'Winget not installed or detected' -Force
|
New-Item -Path "$WorkingDir\logs\error.txt" -Value 'Winget not installed or detected' -Force
|
||||||
Write-ToLog 'End of process!' 'Cyan'
|
Write-ToLog 'End of process!' 'Cyan'
|
||||||
Exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ function Add-ScopeMachine
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$SettingsPath
|
[string]
|
||||||
|
$SettingsPath
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Test-Path -Path $SettingsPath -ErrorAction SilentlyContinue)
|
if (Test-Path -Path $SettingsPath -ErrorAction SilentlyContinue)
|
||||||
|
@ -16,7 +17,8 @@ function Add-ScopeMachine
|
||||||
|
|
||||||
if (!$ConfigFile)
|
if (!$ConfigFile)
|
||||||
{
|
{
|
||||||
$ConfigFile = @{}
|
$ConfigFile = @{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ConfigFile.installBehavior.preferences.scope)
|
if ($ConfigFile.installBehavior.preferences.scope)
|
||||||
|
|
|
@ -4,11 +4,16 @@ function Add-Shortcut
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$Target,
|
[string]
|
||||||
[string]$Shortcut,
|
$Target,
|
||||||
[string]$Arguments,
|
[string]
|
||||||
[string]$Icon,
|
$Shortcut,
|
||||||
[string]$Description
|
[string]
|
||||||
|
$Arguments,
|
||||||
|
[string]
|
||||||
|
$Icon,
|
||||||
|
[string]
|
||||||
|
$Description
|
||||||
)
|
)
|
||||||
|
|
||||||
$WScriptShell = (New-Object -ComObject WScript.Shell)
|
$WScriptShell = (New-Object -ComObject WScript.Shell)
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
Function Confirm-Installation
|
function Confirm-Installation
|
||||||
{
|
{
|
||||||
# Set json export file
|
# Set json export file
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$AppName,
|
[string]
|
||||||
[string]$AppVer
|
$AppName,
|
||||||
|
[string]
|
||||||
|
$AppVer
|
||||||
)
|
)
|
||||||
|
|
||||||
$JsonFile = ('{0}\Config\InstalledApps.json' -f $WorkingDir)
|
$JsonFile = ('{0}\Config\InstalledApps.json' -f $WorkingDir)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# Function to get AZCopy, if it doesn't exist and update it, if it does
|
# Function to get AZCopy, if it doesn't exist and update it, if it does
|
||||||
|
|
||||||
Function Get-AZCopy
|
function Get-AZCopy
|
||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$WingetUpdatePath
|
[string]
|
||||||
|
$WingetUpdatePath
|
||||||
)
|
)
|
||||||
|
|
||||||
$AZCopyLink = (Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -UseBasicParsing -MaximumRedirection 0 -ErrorAction SilentlyContinue).headers.location
|
$AZCopyLink = (Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -UseBasicParsing -MaximumRedirection 0 -ErrorAction SilentlyContinue).headers.location
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
# Get the winget App Information
|
# Get the winget App Information
|
||||||
|
|
||||||
Function Get-AppInfo
|
function Get-AppInfo
|
||||||
{
|
{
|
||||||
# Get AppID Info
|
# Get AppID Info
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$AppID
|
[string]
|
||||||
|
$AppID
|
||||||
)
|
)
|
||||||
|
|
||||||
$String = (& $winget show $AppID --accept-source-agreements -s winget | Out-String)
|
$String = (& $winget show $AppID --accept-source-agreements -s winget | Out-String)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#Function to get the locale file for notifications
|
#Function to get the locale file for notifications
|
||||||
|
|
||||||
Function Get-NotifLocale {
|
function Get-NotifLocale
|
||||||
|
{
|
||||||
|
|
||||||
# Get OS locale
|
# Get OS locale
|
||||||
$OSLocale = (Get-UICulture).Parent
|
$OSLocale = (Get-UICulture).Parent
|
||||||
|
@ -9,11 +10,13 @@ Function Get-NotifLocale {
|
||||||
$TestOSLocalPath = ('{0}\locale\{1}.xml' -f $WorkingDir, $OSLocale.Name)
|
$TestOSLocalPath = ('{0}\locale\{1}.xml' -f $WorkingDir, $OSLocale.Name)
|
||||||
|
|
||||||
# Set OS Local if file exists
|
# Set OS Local if file exists
|
||||||
if (Test-Path -Path $TestOSLocalPath -ErrorAction SilentlyContinue) {
|
if (Test-Path -Path $TestOSLocalPath -ErrorAction SilentlyContinue)
|
||||||
|
{
|
||||||
$LocaleDisplayName = $OSLocale.DisplayName
|
$LocaleDisplayName = $OSLocale.DisplayName
|
||||||
$LocaleFile = $TestOSLocalPath
|
$LocaleFile = $TestOSLocalPath
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
# Set English if file doesn't exist
|
# Set English if file doesn't exist
|
||||||
$LocaleDisplayName = 'English'
|
$LocaleDisplayName = 'English'
|
||||||
$LocaleFile = ('{0}\locale\en.xml' -f $WorkingDir)
|
$LocaleFile = ('{0}\locale\en.xml' -f $WorkingDir)
|
||||||
|
@ -23,6 +26,6 @@ Function Get-NotifLocale {
|
||||||
[xml]$Script:NotifLocale = (Get-Content -Path $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue)
|
[xml]$Script:NotifLocale = (Get-Content -Path $LocaleFile -Encoding UTF8 -ErrorAction SilentlyContinue)
|
||||||
|
|
||||||
# Rerturn langague display name
|
# Rerturn langague display name
|
||||||
Return $LocaleDisplayName
|
return $LocaleDisplayName
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Function to get the Domain/Local Policies (GPO)
|
# Function to get the Domain/Local Policies (GPO)
|
||||||
|
|
||||||
Function Get-Policies
|
function Get-Policies
|
||||||
{
|
{
|
||||||
# Get WAU Policies and set the Configurations Registry Accordingly
|
# Get WAU Policies and set the Configurations Registry Accordingly
|
||||||
$WAUPolicies = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate' -ErrorAction SilentlyContinue)
|
$WAUPolicies = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate' -ErrorAction SilentlyContinue)
|
||||||
|
@ -196,7 +196,8 @@ Function Get-Policies
|
||||||
$task = $folder.GetTask('Winget-AutoUpdate')
|
$task = $folder.GetTask('Winget-AutoUpdate')
|
||||||
$definition = $task.Definition
|
$definition = $task.Definition
|
||||||
$null = $definition.Triggers.Count
|
$null = $definition.Triggers.Count
|
||||||
switch ($($WAUPolicies.WAU_UpdatesInterval)) {
|
switch ($($WAUPolicies.WAU_UpdatesInterval))
|
||||||
|
{
|
||||||
'Daily'
|
'Daily'
|
||||||
{
|
{
|
||||||
$tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime)
|
$tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime)
|
||||||
|
@ -466,5 +467,5 @@ Function Get-Policies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Return $($WAUPolicies.WAU_ActivateGPOManagement), $ChangedSettings
|
return $($WAUPolicies.WAU_ActivateGPOManagement), $ChangedSettings
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,41 @@
|
||||||
# Function to get the winget command regarding execution context (User, System...)
|
# Function to get the winget command regarding execution context (User, System...)
|
||||||
|
|
||||||
Function Get-WingetCmd {
|
function Get-WingetCmd
|
||||||
|
{
|
||||||
|
|
||||||
# Get WinGet Path (if Admin context)
|
# Get WinGet Path (if Admin context)
|
||||||
# Includes Workaround for ARM64 (removed X64 and replaces it with a wildcard)
|
# Includes Workaround for ARM64 (removed X64 and replaces it with a wildcard)
|
||||||
$ResolveWingetPath = (Resolve-Path -Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe" | Sort-Object -Property { [version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1') })
|
$ResolveWingetPath = (Resolve-Path -Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe" | Sort-Object -Property {
|
||||||
|
[version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1')
|
||||||
|
})
|
||||||
|
|
||||||
if ($ResolveWingetPath) {
|
if ($ResolveWingetPath)
|
||||||
|
{
|
||||||
# If multiple version, pick last one
|
# If multiple version, pick last one
|
||||||
$WingetPath = $ResolveWingetPath[-1].Path
|
$WingetPath = $ResolveWingetPath[-1].Path
|
||||||
}
|
}
|
||||||
|
|
||||||
#If running under System or Admin context obtain Winget from Program Files
|
#If running under System or Admin context obtain Winget from Program Files
|
||||||
if((([Security.Principal.WindowsIdentity]::GetCurrent().User) -eq 'S-1-5-18') -or ($WingetPath)){
|
if ((([Security.Principal.WindowsIdentity]::GetCurrent().User) -eq 'S-1-5-18') -or ($WingetPath))
|
||||||
if (Test-Path -Path ('{0}\winget.exe' -f $WingetPath) -ErrorAction SilentlyContinue) {
|
{
|
||||||
|
if (Test-Path -Path ('{0}\winget.exe' -f $WingetPath) -ErrorAction SilentlyContinue)
|
||||||
|
{
|
||||||
$Script:Winget = ('{0}\winget.exe' -f $WingetPath)
|
$Script:Winget = ('{0}\winget.exe' -f $WingetPath)
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#Get Winget Location in User context
|
#Get Winget Location in User context
|
||||||
$WingetCmd = (Get-Command -Name winget.exe -ErrorAction SilentlyContinue)
|
$WingetCmd = (Get-Command -Name winget.exe -ErrorAction SilentlyContinue)
|
||||||
|
|
||||||
if ($WingetCmd) {
|
if ($WingetCmd)
|
||||||
|
{
|
||||||
$Script:Winget = $WingetCmd.Source
|
$Script:Winget = $WingetCmd.Source
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
If(!($Script:Winget)){
|
if (!($Script:Winget))
|
||||||
|
{
|
||||||
Write-ToLog 'Winget not installed or detected !' 'Red'
|
Write-ToLog 'Winget not installed or detected !' 'Red'
|
||||||
|
|
||||||
return $false
|
return $false
|
||||||
|
|
|
@ -44,7 +44,7 @@ function Get-WingetOutdatedApps
|
||||||
# Now cycle in real package and split accordingly
|
# Now cycle in real package and split accordingly
|
||||||
$upgradeList = @()
|
$upgradeList = @()
|
||||||
|
|
||||||
For ($i = $fl + 2; $i -lt $lines.Length; $i++)
|
for ($i = $fl + 2; $i -lt $lines.Length; $i++)
|
||||||
{
|
{
|
||||||
$line = $lines[$i] -replace '[\u2026]', ' ' #Fix "..." in long names
|
$line = $lines[$i] -replace '[\u2026]', ' ' #Fix "..." in long names
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,12 @@ function Invoke-LogRotation
|
||||||
#>
|
#>
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$LogFile,
|
[string]
|
||||||
[int]$MaxLogFiles,
|
$LogFile,
|
||||||
[int]$MaxLogSize
|
[int]
|
||||||
|
$MaxLogFiles,
|
||||||
|
[int]
|
||||||
|
$MaxLogSize
|
||||||
)
|
)
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -59,7 +62,7 @@ function Invoke-LogRotation
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Return $False
|
return $False
|
||||||
}
|
}
|
||||||
|
|
||||||
# if MaxLogFiles is 0 don't delete any old archived log files
|
# if MaxLogFiles is 0 don't delete any old archived log files
|
||||||
|
@ -104,12 +107,12 @@ function Invoke-LogRotation
|
||||||
|
|
||||||
Write-ToLog -LogMsg ('Max Log Size reached: {0} bytes - Rotated Logs' -f $MaxLogSize)
|
Write-ToLog -LogMsg ('Max Log Size reached: {0} bytes - Rotated Logs' -f $MaxLogSize)
|
||||||
|
|
||||||
Return $True
|
return $True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Return $False
|
return $False
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@ function Invoke-ModsProtect
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$ModsPath
|
[string]
|
||||||
|
$ModsPath
|
||||||
)
|
)
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -69,11 +69,11 @@ function Invoke-PostUpdateActions
|
||||||
}
|
}
|
||||||
|
|
||||||
# Current: v1.5.2201 = 1.20.2201.0 = 2023.808.2243.0
|
# Current: v1.5.2201 = 1.20.2201.0 = 2023.808.2243.0
|
||||||
If ([Version]$TestWinGet.Version -ge '2023.808.2243.0')
|
if ([Version]$TestWinGet.Version -ge '2023.808.2243.0')
|
||||||
{
|
{
|
||||||
Write-ToLog -LogMsg '-> WinGet is Installed/up to date' -LogColor 'green'
|
Write-ToLog -LogMsg '-> WinGet is Installed/up to date' -LogColor 'green'
|
||||||
}
|
}
|
||||||
Else
|
else
|
||||||
{
|
{
|
||||||
# Download WinGet MSIXBundle
|
# Download WinGet MSIXBundle
|
||||||
Write-ToLog -LogMsg '-> Not installed/up to date. Downloading WinGet...'
|
Write-ToLog -LogMsg '-> Not installed/up to date. Downloading WinGet...'
|
||||||
|
|
|
@ -4,16 +4,26 @@ function Start-NotifTask
|
||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[String]$Title = 'Winget-AutoUpdate',
|
[String]
|
||||||
[String]$Message,
|
$Title = 'Winget-AutoUpdate',
|
||||||
[String]$MessageType,
|
[String]
|
||||||
[String]$Balise = 'WAU',
|
$Message,
|
||||||
[String]$OnClickAction,
|
[String]
|
||||||
[String]$Body,
|
$MessageType,
|
||||||
[String]$Button1Text,
|
[String]
|
||||||
[String]$Button1Action,
|
$Balise = 'WAU',
|
||||||
[Switch]$ButtonDismiss = $false,
|
[String]
|
||||||
[Switch]$UserRun = $false
|
$OnClickAction,
|
||||||
|
[String]
|
||||||
|
$Body,
|
||||||
|
[String]
|
||||||
|
$Button1Text,
|
||||||
|
[String]
|
||||||
|
$Button1Action,
|
||||||
|
[Switch]
|
||||||
|
$ButtonDismiss = $false,
|
||||||
|
[Switch]
|
||||||
|
$UserRun = $false
|
||||||
)
|
)
|
||||||
|
|
||||||
if (($WAUConfig.WAU_NotificationLevel -eq 'Full') -or ($WAUConfig.WAU_NotificationLevel -eq 'SuccessOnly' -and $MessageType -eq 'Success') -or ($UserRun))
|
if (($WAUConfig.WAU_NotificationLevel -eq 'Full') -or ($WAUConfig.WAU_NotificationLevel -eq 'SuccessOnly' -and $MessageType -eq 'Success') -or ($UserRun))
|
||||||
|
|
|
@ -6,9 +6,12 @@ function Test-ListPath
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$ListPath,
|
[string]
|
||||||
[string]$UseWhiteList,
|
$ListPath,
|
||||||
[string]$WingetUpdatePath
|
[string]
|
||||||
|
$UseWhiteList,
|
||||||
|
[string]
|
||||||
|
$WingetUpdatePath
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($UseWhiteList)
|
if ($UseWhiteList)
|
||||||
|
|
|
@ -6,7 +6,8 @@ function Test-Mods
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$app
|
[string]
|
||||||
|
$app
|
||||||
)
|
)
|
||||||
|
|
||||||
$ModsPreInstall = $null
|
$ModsPreInstall = $null
|
||||||
|
|
|
@ -8,9 +8,12 @@ function Test-ModsPath
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$ModsPath,
|
[string]
|
||||||
[string]$WingetUpdatePath,
|
$ModsPath,
|
||||||
[string]$AzureBlobSASURL
|
[string]
|
||||||
|
$WingetUpdatePath,
|
||||||
|
[string]
|
||||||
|
$AzureBlobSASURL
|
||||||
)
|
)
|
||||||
$LocalMods = -join ($WingetUpdatePath, '\', 'mods')
|
$LocalMods = -join ($WingetUpdatePath, '\', 'mods')
|
||||||
$ExternalMods = $ModsPath
|
$ExternalMods = $ModsPath
|
||||||
|
@ -64,7 +67,7 @@ function Test-ModsPath
|
||||||
|
|
||||||
foreach ($Bin in $InternalBinsNames)
|
foreach ($Bin in $InternalBinsNames)
|
||||||
{
|
{
|
||||||
If ($CleanLinks -notcontains $Bin)
|
if ($CleanLinks -notcontains $Bin)
|
||||||
{
|
{
|
||||||
$null = (Remove-Item -Path $LocalMods\bins\$Bin -Force -Confirm:$False -ErrorAction SilentlyContinue)
|
$null = (Remove-Item -Path $LocalMods\bins\$Bin -Force -Confirm:$False -ErrorAction SilentlyContinue)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +125,7 @@ function Test-ModsPath
|
||||||
|
|
||||||
foreach ($Mod in $InternalModsNames)
|
foreach ($Mod in $InternalModsNames)
|
||||||
{
|
{
|
||||||
If ($CleanLinks -notcontains $Mod)
|
if ($CleanLinks -notcontains $Mod)
|
||||||
{
|
{
|
||||||
$null = (Remove-Item -Path $LocalMods\$Mod -Force -Confirm:$False -ErrorAction SilentlyContinue)
|
$null = (Remove-Item -Path $LocalMods\$Mod -Force -Confirm:$False -ErrorAction SilentlyContinue)
|
||||||
$DeletedMods++
|
$DeletedMods++
|
||||||
|
@ -235,7 +238,7 @@ function Test-ModsPath
|
||||||
# Delete Local Bins that don't exist Externally
|
# Delete Local Bins that don't exist Externally
|
||||||
foreach ($Bin in $InternalBinsNames)
|
foreach ($Bin in $InternalBinsNames)
|
||||||
{
|
{
|
||||||
If ($Bin -notin $ExternalBinsNames )
|
if ($Bin -notin $ExternalBinsNames)
|
||||||
{
|
{
|
||||||
$null = (Remove-Item -Path $LocalMods\bins\$Bin -Force -Confirm:$False -ErrorAction SilentlyContinue)
|
$null = (Remove-Item -Path $LocalMods\bins\$Bin -Force -Confirm:$False -ErrorAction SilentlyContinue)
|
||||||
}
|
}
|
||||||
|
@ -271,7 +274,7 @@ function Test-ModsPath
|
||||||
|
|
||||||
foreach ($Mod in $InternalModsNames)
|
foreach ($Mod in $InternalModsNames)
|
||||||
{
|
{
|
||||||
If ($Mod -notin $ExternalModsNames )
|
if ($Mod -notin $ExternalModsNames)
|
||||||
{
|
{
|
||||||
$null = Remove-Item -Path $LocalMods\$Mod -Force -ErrorAction SilentlyContinue
|
$null = Remove-Item -Path $LocalMods\$Mod -Force -ErrorAction SilentlyContinue
|
||||||
$DeletedMods++
|
$DeletedMods++
|
||||||
|
|
|
@ -8,7 +8,7 @@ function Test-Network
|
||||||
|
|
||||||
# Test connectivity during 30 min then timeout
|
# Test connectivity during 30 min then timeout
|
||||||
Write-ToLog -LogMsg 'Checking internet connection...' -LogColor 'Yellow'
|
Write-ToLog -LogMsg 'Checking internet connection...' -LogColor 'Yellow'
|
||||||
While ($timeout -lt 1800)
|
while ($timeout -lt 1800)
|
||||||
{
|
{
|
||||||
$URLtoTest = 'https://raw.githubusercontent.com/Romanitho/Winget-AutoUpdate/main/LICENSE'
|
$URLtoTest = 'https://raw.githubusercontent.com/Romanitho/Winget-AutoUpdate/main/LICENSE'
|
||||||
$URLcontent = ((Invoke-WebRequest -Uri $URLtoTest -UseBasicParsing).content)
|
$URLcontent = ((Invoke-WebRequest -Uri $URLtoTest -UseBasicParsing).content)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Function to update an App
|
# Function to update an App
|
||||||
|
|
||||||
Function Update-App
|
function Update-App
|
||||||
{
|
{
|
||||||
# Get App Info
|
# Get App Info
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
|
|
|
@ -6,8 +6,10 @@ function Write-ToLog
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[string]$LogMsg,
|
[string]
|
||||||
[string]$LogColor = 'White'
|
$LogMsg,
|
||||||
|
[string]
|
||||||
|
$LogColor = 'White'
|
||||||
)
|
)
|
||||||
|
|
||||||
$Log = ('{0} - {1}' -f (Get-Date -UFormat '%T'), $LogMsg)
|
$Log = ('{0} - {1}' -f (Get-Date -UFormat '%T'), $LogMsg)
|
||||||
|
|
Loading…
Reference in New Issue