Small optical code improvements
parent
31f2314812
commit
c23f3d6883
|
@ -4,7 +4,7 @@ Configure Winget to daily update installed apps.
|
|||
|
||||
.DESCRIPTION
|
||||
Install powershell scripts and scheduled task to daily run Winget upgrade and notify connected users.
|
||||
Possible to exclude apps from auto-update
|
||||
Posibility to exclude apps from auto-update
|
||||
https://github.com/Romanitho/Winget-AutoUpdate
|
||||
|
||||
.PARAMETER Silent
|
||||
|
@ -111,7 +111,7 @@ param(
|
|||
[Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"),
|
||||
[Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false,
|
||||
[Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false,
|
||||
[Parameter(Mandatory = $False)] [ValidateRange(0,99)] [int32] $MaxLogFiles = 3,
|
||||
[Parameter(Mandatory = $False)] [ValidateRange(0, 99)] [int32] $MaxLogFiles = 3,
|
||||
[Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
|
||||
)
|
||||
|
||||
|
@ -391,7 +391,7 @@ function Install-WingetAutoUpdate {
|
|||
else {
|
||||
Write-Host "Error: The mods directory couldn't be verified as secured!`n" -ForegroundColor Red
|
||||
}
|
||||
|
||||
|
||||
#Create Shortcuts
|
||||
if ($StartMenuShortcut) {
|
||||
if (!(Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Handle user interaction from shortcuts and show a Toast
|
||||
Handle user interaction from shortcuts and show a Toast notification
|
||||
|
||||
.DESCRIPTION
|
||||
Act on shortcut run (DEFAULT: Check for updated Apps)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Uninstall Winget-AutoUpdate
|
||||
|
||||
.DESCRIPTION
|
||||
Uninstall Winget-AutoUpdate (DEFAULT: clean old install)
|
||||
Uninstalls Winget-AutoUpdate (DEFAULT: clean old install)
|
||||
https://github.com/Romanitho/Winget-AutoUpdate
|
||||
|
||||
.PARAMETER NoClean
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Send Notif Script
|
||||
#Send Notify Script
|
||||
|
||||
#get xml notif config
|
||||
$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<# LOAD FUNCTIONS #>
|
||||
|
||||
#Get Working Dir
|
||||
#Get the Working Dir
|
||||
$Script:WorkingDir = $PSScriptRoot
|
||||
#Get Functions
|
||||
Get-ChildItem "$WorkingDir\functions" | ForEach-Object { . $_.FullName }
|
||||
|
@ -41,7 +41,7 @@ if ($IsSystem) {
|
|||
else {
|
||||
[int32] $MaxLogFiles = $MaxLogFiles
|
||||
}
|
||||
|
||||
|
||||
# Maximum size of log file.
|
||||
$MaxLogSize = $WAUConfig.WAU_MaxLogSize
|
||||
if (!$MaxLogSize) {
|
||||
|
@ -147,7 +147,7 @@ if (Test-Network) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#Get External ModsPath if run as System
|
||||
if ($WAUConfig.WAU_ModsPath) {
|
||||
$ModsPathClean = $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/"))
|
||||
|
@ -289,12 +289,10 @@ if (Test-Network) {
|
|||
if ($IsSystem) {
|
||||
#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)
|
||||
If ($explorerprocesses.Count -eq 0)
|
||||
{
|
||||
If ($explorerprocesses.Count -eq 0) {
|
||||
Write-Log "No explorer process found / Nobody interactively logged on..."
|
||||
}
|
||||
Else
|
||||
{
|
||||
Else {
|
||||
#Run WAU in user context if the user task exist
|
||||
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
|
||||
if ($UserScheduledTask) {
|
||||
|
@ -308,10 +306,10 @@ if (Test-Network) {
|
|||
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
|
||||
Exit 0
|
||||
}
|
||||
elseif (!$UserScheduledTask){
|
||||
elseif (!$UserScheduledTask) {
|
||||
Write-Log "User context execution not installed..."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to configure prefered scope option as Machine
|
||||
#Function to configure the prefered scope option as Machine
|
||||
function Add-ScopeMachine ($SettingsPath) {
|
||||
|
||||
if (Test-Path $SettingsPath) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function for creating shortcuts
|
||||
#Function to create shortcuts
|
||||
function Add-Shortcut ($Target, $Shortcut, $Arguments, $Icon, $Description) {
|
||||
$WScriptShell = New-Object -ComObject WScript.Shell
|
||||
$Shortcut = $WScriptShell.CreateShortcut($Shortcut)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#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 ($WingetUpdatePath){
|
||||
Function Get-AZCopy ($WingetUpdatePath) {
|
||||
|
||||
$AZCopyLink = (Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -UseBasicParsing -MaximumRedirection 0 -ErrorAction SilentlyContinue).headers.location
|
||||
$AZCopyVersionRegex = [regex]::new("(\d+\.\d+\.\d+)")
|
||||
|
@ -12,23 +12,23 @@ Function Get-AZCopy ($WingetUpdatePath){
|
|||
|
||||
if (Test-Path -Path "$WingetUpdatePath\azcopy.exe" -PathType Leaf) {
|
||||
$AZCopyCurrentVersion = & "$WingetUpdatePath\azcopy.exe" -v
|
||||
$AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value
|
||||
Write-Log "AZCopy version $AZCopyCurrentVersion found"
|
||||
$AZCopyCurrentVersion = $AZCopyVersionRegex.Match($AZCopyCurrentVersion).Value
|
||||
Write-Log "AZCopy version $AZCopyCurrentVersion found"
|
||||
}
|
||||
else {
|
||||
Write-Log "AZCopy not already installed"
|
||||
Write-Log "AZCopy not already installed"
|
||||
$AZCopyCurrentVersion = "0.0.0"
|
||||
}
|
||||
|
||||
if (([version] $AZCopyCurrentVersion) -lt ([version] $AZCopyLatestVersion)) {
|
||||
Write-Log "Installing version $AZCopyLatestVersion of AZCopy"
|
||||
Write-Log "Installing version $AZCopyLatestVersion of AZCopy"
|
||||
Invoke-WebRequest -Uri $AZCopyLink -UseBasicParsing -OutFile "$WingetUpdatePath\azcopyv10.zip"
|
||||
Write-Log "Extracting AZCopy zip file"
|
||||
|
||||
Expand-archive -Path "$WingetUpdatePath\azcopyv10.zip" -Destinationpath "$WingetUpdatePath" -Force
|
||||
|
||||
$AZCopyPathSearch = Resolve-Path -path "$WingetUpdatePath\azcopy_*"
|
||||
|
||||
$AZCopyPathSearch = Resolve-Path -path "$WingetUpdatePath\azcopy_*"
|
||||
|
||||
if ($AZCopyPathSearch -is [array]) {
|
||||
$AZCopyEXEPath = $AZCopyPathSearch[$AZCopyPathSearch.Length - 1]
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Get App Info
|
||||
#Get the winget App Information
|
||||
|
||||
Function Get-AppInfo ($AppID) {
|
||||
#Get AppID Info
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
#Function to get Black List apps
|
||||
#Function to get the Block List apps
|
||||
|
||||
function Get-ExcludedApps {
|
||||
|
||||
if ($GPOList) {
|
||||
|
||||
|
||||
if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList") {
|
||||
|
||||
$Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList\'
|
||||
|
||||
$ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property
|
||||
|
||||
|
||||
foreach ($ValueName in $ValueNames) {
|
||||
$AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false)
|
||||
[PSCustomObject]@{
|
||||
Value = $ValueName
|
||||
Data = $AppIDs.Trim()
|
||||
Data = $AppIDs.Trim()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $AppIDs
|
||||
|
||||
|
||||
}
|
||||
elseif (Test-Path "$WorkingDir\excluded_apps.txt") {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to get White List apps
|
||||
#Function to get the allow List apps
|
||||
|
||||
function Get-IncludedApps {
|
||||
|
||||
|
@ -9,15 +9,15 @@ function Get-IncludedApps {
|
|||
$Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList\'
|
||||
|
||||
$ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property
|
||||
|
||||
|
||||
foreach ($ValueName in $ValueNames) {
|
||||
$AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false)
|
||||
[PSCustomObject]@{
|
||||
Value = $ValueName
|
||||
Data = $AppIDs.Trim()
|
||||
Data = $AppIDs.Trim()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $AppIDs
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to get locale file for Notification.
|
||||
#Function to get the locale file for notifications
|
||||
|
||||
Function Get-NotifLocale {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to get Domain/Local Policies (GPO)
|
||||
#Function to get the Domain/Local Policies (GPO)
|
||||
|
||||
Function Get-Policies {
|
||||
#Get WAU Policies and set the Configurations Registry Accordingly
|
||||
|
@ -15,7 +15,7 @@ Function Get-Policies {
|
|||
Remove-ItemProperty $regPath -Name WAU_BypassListForUsers -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$ChangedSettings++
|
||||
}
|
||||
|
||||
|
||||
if ($null -ne $($WAUPolicies.WAU_DisableAutoUpdate) -and ($($WAUPolicies.WAU_DisableAutoUpdate) -ne $($WAUConfig.WAU_DisableAutoUpdate))) {
|
||||
New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value $($WAUPolicies.WAU_DisableAutoUpdate) -PropertyType DWord -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
|
@ -24,7 +24,7 @@ Function Get-Policies {
|
|||
Remove-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$ChangedSettings++
|
||||
}
|
||||
|
||||
|
||||
if ($null -ne $($WAUPolicies.WAU_DoNotRunOnMetered) -and ($($WAUPolicies.WAU_DoNotRunOnMetered) -ne $($WAUConfig.WAU_DoNotRunOnMetered))) {
|
||||
New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value $($WAUPolicies.WAU_DoNotRunOnMetered) -PropertyType DWord -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
|
@ -33,7 +33,7 @@ Function Get-Policies {
|
|||
New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
}
|
||||
|
||||
|
||||
if ($null -ne $($WAUPolicies.WAU_UpdatePrerelease) -and ($($WAUPolicies.WAU_UpdatePrerelease) -ne $($WAUConfig.WAU_UpdatePrerelease))) {
|
||||
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value $($WAUPolicies.WAU_UpdatePrerelease) -PropertyType DWord -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
|
@ -42,7 +42,7 @@ Function Get-Policies {
|
|||
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
}
|
||||
|
||||
|
||||
if ($null -ne $($WAUPolicies.WAU_UseWhiteList) -and ($($WAUPolicies.WAU_UseWhiteList) -ne $($WAUConfig.WAU_UseWhiteList))) {
|
||||
New-ItemProperty $regPath -Name WAU_UseWhiteList -Value $($WAUPolicies.WAU_UseWhiteList) -PropertyType DWord -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
|
@ -51,7 +51,7 @@ Function Get-Policies {
|
|||
Remove-ItemProperty $regPath -Name WAU_UseWhiteList -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$ChangedSettings++
|
||||
}
|
||||
|
||||
|
||||
if ($null -ne $($WAUPolicies.WAU_ListPath) -and ($($WAUPolicies.WAU_ListPath) -ne $($WAUConfig.WAU_ListPath))) {
|
||||
New-ItemProperty $regPath -Name WAU_ListPath -Value $($WAUPolicies.WAU_ListPath.TrimEnd(" ", "\", "/")) -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
|
@ -60,7 +60,7 @@ Function Get-Policies {
|
|||
Remove-ItemProperty $regPath -Name WAU_ListPath -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$ChangedSettings++
|
||||
}
|
||||
|
||||
|
||||
if ($null -ne $($WAUPolicies.WAU_ModsPath) -and ($($WAUPolicies.WAU_ModsPath) -ne $($WAUConfig.WAU_ModsPath))) {
|
||||
New-ItemProperty $regPath -Name WAU_ModsPath -Value $($WAUPolicies.WAU_ModsPath.TrimEnd(" ", "\", "/")) -Force | Out-Null
|
||||
$ChangedSettings++
|
||||
|
@ -95,14 +95,14 @@ Function Get-Policies {
|
|||
$folder = $service.GetFolder('\')
|
||||
$task = $folder.GetTask("Winget-AutoUpdate")
|
||||
$definition = $task.Definition
|
||||
for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){
|
||||
if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){
|
||||
$PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0,11)
|
||||
$PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19,6)
|
||||
for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) {
|
||||
if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) {
|
||||
$PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0, 11)
|
||||
$PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19, 6)
|
||||
$Boundary = $PreStartBoundary + $($WAUPolicies.WAU_UpdatesAtTime) + $PostStartBoundary
|
||||
$definition.Triggers.Item($triggerId).StartBoundary = $Boundary
|
||||
break
|
||||
$triggerId-=1
|
||||
$triggerId -= 1
|
||||
}
|
||||
}
|
||||
$folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null
|
||||
|
@ -116,14 +116,14 @@ Function Get-Policies {
|
|||
$folder = $service.GetFolder('\')
|
||||
$task = $folder.GetTask("Winget-AutoUpdate")
|
||||
$definition = $task.Definition
|
||||
for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){
|
||||
if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){
|
||||
$PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0,11)
|
||||
$PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19,6)
|
||||
for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) {
|
||||
if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) {
|
||||
$PreStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(0, 11)
|
||||
$PostStartBoundary = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(19, 6)
|
||||
$Boundary = $PreStartBoundary + "06:00:00" + $PostStartBoundary
|
||||
$definition.Triggers.Item($triggerId).StartBoundary = $Boundary
|
||||
break
|
||||
$triggerId-=1
|
||||
$triggerId -= 1
|
||||
}
|
||||
}
|
||||
$folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null
|
||||
|
@ -137,11 +137,11 @@ Function Get-Policies {
|
|||
$folder = $service.GetFolder('\')
|
||||
$task = $folder.GetTask("Winget-AutoUpdate")
|
||||
$definition = $task.Definition
|
||||
for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){
|
||||
if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){
|
||||
$UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11,8)
|
||||
for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) {
|
||||
if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) {
|
||||
$UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11, 8)
|
||||
$definition.Triggers.Remove($triggerId)
|
||||
$triggerId-=1
|
||||
$triggerId -= 1
|
||||
}
|
||||
}
|
||||
$folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null
|
||||
|
@ -160,11 +160,11 @@ Function Get-Policies {
|
|||
$definition = $task.Definition
|
||||
$definition.Triggers.Count | Out-Null
|
||||
switch ($($WAUPolicies.WAU_UpdatesInterval)) {
|
||||
"Daily" {$tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime); break}
|
||||
"BiDaily" {$tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime) -DaysInterval 2; break}
|
||||
"Weekly" {$tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2; break}
|
||||
"BiWeekly" {$tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 2; break}
|
||||
"Monthly" {$tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 4; break}
|
||||
"Daily" { $tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime); break }
|
||||
"BiDaily" { $tasktrigger = New-ScheduledTaskTrigger -Daily -At $($WAUConfig.WAU_UpdatesAtTime) -DaysInterval 2; break }
|
||||
"Weekly" { $tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2; break }
|
||||
"BiWeekly" { $tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 2; break }
|
||||
"Monthly" { $tasktrigger = New-ScheduledTaskTrigger -Weekly -At $($WAUConfig.WAU_UpdatesAtTime) -DaysOfWeek 2 -WeeksInterval 4; break }
|
||||
}
|
||||
if ($definition.Triggers.Count -gt 0) {
|
||||
$triggers = @()
|
||||
|
@ -185,11 +185,11 @@ Function Get-Policies {
|
|||
$folder = $service.GetFolder('\')
|
||||
$task = $folder.GetTask("Winget-AutoUpdate")
|
||||
$definition = $task.Definition
|
||||
for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){
|
||||
if(($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")){
|
||||
$UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11,8)
|
||||
for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) {
|
||||
if (($definition.Triggers.Item($triggerId).Type -eq "2") -or ($definition.Triggers.Item($triggerId).Type -eq "3")) {
|
||||
$UpdatesAtTime = ($definition.Triggers.Item($triggerId).StartBoundary).Substring(11, 8)
|
||||
$definition.Triggers.Remove($triggerId)
|
||||
$triggerId-=1
|
||||
$triggerId -= 1
|
||||
}
|
||||
}
|
||||
$folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null
|
||||
|
@ -251,10 +251,10 @@ Function Get-Policies {
|
|||
$task = $folder.GetTask("Winget-AutoUpdate")
|
||||
$definition = $task.Definition
|
||||
$definition.Triggers.Count | Out-Null
|
||||
for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){
|
||||
if($definition.Triggers.Item($triggerId).Type -eq "9"){
|
||||
for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) {
|
||||
if ($definition.Triggers.Item($triggerId).Type -eq "9") {
|
||||
$definition.Triggers.Remove($triggerId)
|
||||
$triggerId-=1
|
||||
$triggerId -= 1
|
||||
}
|
||||
}
|
||||
$folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null
|
||||
|
@ -268,10 +268,10 @@ Function Get-Policies {
|
|||
$folder = $service.GetFolder('\')
|
||||
$task = $folder.GetTask("Winget-AutoUpdate")
|
||||
$definition = $task.Definition
|
||||
for($triggerId=1; $triggerId -le $definition.Triggers.Count; $triggerId++){
|
||||
if($definition.Triggers.Item($triggerId).Type -eq "9"){
|
||||
for ($triggerId = 1; $triggerId -le $definition.Triggers.Count; $triggerId++) {
|
||||
if ($definition.Triggers.Item($triggerId).Type -eq "9") {
|
||||
$definition.Triggers.Remove($triggerId)
|
||||
$triggerId-=1
|
||||
$triggerId -= 1
|
||||
}
|
||||
}
|
||||
$folder.RegisterTaskDefinition($task.Name, $definition, 4, $null, $null, $null) | Out-Null
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to get latest WAU available version on Github
|
||||
#Function to get the latest WAU available version on Github
|
||||
|
||||
function Get-WAUAvailableVersion {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to get Winget Command regarding execution context (User, System...)
|
||||
#Function to get the winget command regarding execution context (User, System...)
|
||||
|
||||
Function Get-WingetCmd {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to get outdated app list, in formatted array
|
||||
#Function to get the outdated app list, in formatted array
|
||||
|
||||
function Get-WingetOutdatedApps {
|
||||
class Software {
|
||||
|
@ -51,8 +51,8 @@ function Get-WingetOutdatedApps {
|
|||
$idStart = $lines[$fl].IndexOf($index[1])
|
||||
$versionStart = $lines[$fl].IndexOf($index[2])
|
||||
$availableStart = $lines[$fl].IndexOf($index[3])
|
||||
}
|
||||
#(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications
|
||||
}
|
||||
#(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications
|
||||
if ($line -match "\w\.\w") {
|
||||
$software = [Software]::new()
|
||||
$software.Name = $line.Substring(0, $idStart).TrimEnd()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function Get-WingetSystemApps {
|
||||
|
||||
#Json File where to export system installed apps
|
||||
#Json File, where to export system installed apps
|
||||
$jsonFile = "$WorkingDir\winget_system_apps.txt"
|
||||
|
||||
#Get list of installed Winget apps to json file
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function rotate the logs
|
||||
#Function to rotate the logs
|
||||
|
||||
function Invoke-LogRotation ($LogFile, $MaxLogFiles, $MaxLogSize) {
|
||||
<#
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to check if Mods Directory is secured.
|
||||
#Function to check if the mods directory is secured.
|
||||
#Security: Mods directory must be protected (Users could create scripts of their own - then they'll run in System Context)!
|
||||
#Check if Local Users have write rights in Mods directory or not (and take action if necessary):
|
||||
|
||||
|
@ -12,16 +12,16 @@ function Invoke-ModsProtect ($ModsPath) {
|
|||
$ntAccount = $userSID.Translate([System.Security.Principal.NTAccount])
|
||||
$userName = $ntAccount.Value
|
||||
$userRights = [System.Security.AccessControl.FileSystemRights]"Write"
|
||||
|
||||
|
||||
$hasWriteAccess = $False
|
||||
|
||||
|
||||
foreach ($access in $acl.Access) {
|
||||
if ($access.IdentityReference.Value -eq $userName -and $access.FileSystemRights -eq $userRights) {
|
||||
$hasWriteAccess = $True
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($hasWriteAccess) {
|
||||
#Disable inheritance
|
||||
$acl.SetAccessRuleProtection($True, $True)
|
||||
|
@ -29,32 +29,32 @@ function Invoke-ModsProtect ($ModsPath) {
|
|||
$acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) }
|
||||
#SYSTEM Full - S-1-5-18
|
||||
$userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-18")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
|
||||
$acl.SetAccessRule($rule)
|
||||
# Save the updated ACL
|
||||
Set-Acl -Path $directory.FullName -AclObject $acl
|
||||
|
||||
|
||||
#Administrators Full - S-1-5-32-544
|
||||
$acl = Get-Acl -Path $directory.FullName
|
||||
$userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID,"FullControl","ContainerInherit,ObjectInherit","None","Allow")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
|
||||
$acl.SetAccessRule($rule)
|
||||
Set-Acl -Path $directory.FullName -AclObject $acl
|
||||
|
||||
|
||||
#Local Users ReadAndExecute - S-1-5-32-545 S-1-5-11
|
||||
$acl = Get-Acl -Path $directory.FullName
|
||||
$userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute", "ContainerInherit,ObjectInherit", "None", "Allow")
|
||||
$acl.SetAccessRule($rule)
|
||||
Set-Acl -Path $directory.FullName -AclObject $acl
|
||||
|
||||
|
||||
#Authenticated Users ReadAndExecute - S-1-5-11
|
||||
$acl = Get-Acl -Path $directory.FullName
|
||||
$userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-11")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow")
|
||||
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($userSID, "ReadAndExecute", "ContainerInherit,ObjectInherit", "None", "Allow")
|
||||
$acl.SetAccessRule($rule)
|
||||
Set-Acl -Path $directory.FullName -AclObject $acl
|
||||
|
||||
|
||||
return $True
|
||||
}
|
||||
return $False
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to make actions post WAU update
|
||||
#Function to make actions after WAU update
|
||||
|
||||
function Invoke-PostUpdateActions {
|
||||
|
||||
|
@ -12,7 +12,7 @@ function Invoke-PostUpdateActions {
|
|||
}
|
||||
|
||||
Write-Log "-> Checking prerequisites..." "yellow"
|
||||
|
||||
|
||||
#Check if Visual C++ 2019 or 2022 installed
|
||||
$Visual2019 = "Microsoft Visual C++ 2015-2019 Redistributable*"
|
||||
$Visual2022 = "Microsoft Visual C++ 2015-2022 Redistributable*"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Initialisation
|
||||
# Initialisation
|
||||
|
||||
function Start-Init {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to send notifications to user
|
||||
#Function to send the notifications to user
|
||||
|
||||
function Start-NotifTask {
|
||||
|
||||
|
@ -31,7 +31,7 @@ function Start-NotifTask {
|
|||
$XMLbinding.Attributes.Append($XMLbindingAtt1) | Out-Null
|
||||
|
||||
$XMLimagepath = "$WorkingDir\icons\$MessageType.png"
|
||||
if (Test-Path $XMLimagepath){
|
||||
if (Test-Path $XMLimagepath) {
|
||||
# Creation of a image node
|
||||
$XMLimage = $ToastTemplate.CreateElement("image")
|
||||
$XMLbinding.AppendChild($XMLimage) | Out-Null
|
||||
|
@ -43,7 +43,7 @@ function Start-NotifTask {
|
|||
$XMLimage.Attributes.Append($XMLimageAtt2) | Out-Null
|
||||
}
|
||||
|
||||
if ($Title){
|
||||
if ($Title) {
|
||||
# Creation of a text node
|
||||
$XMLtitle = $ToastTemplate.CreateElement("text")
|
||||
$XMLtitleText = $ToastTemplate.CreateTextNode($Title)
|
||||
|
@ -51,7 +51,7 @@ function Start-NotifTask {
|
|||
$XMLbinding.AppendChild($XMLtitle) | Out-Null
|
||||
}
|
||||
|
||||
if ($Message){
|
||||
if ($Message) {
|
||||
# Creation of a text node
|
||||
$XMLtext = $ToastTemplate.CreateElement("text")
|
||||
$XMLtextText = $ToastTemplate.CreateTextNode($Message)
|
||||
|
@ -59,7 +59,7 @@ function Start-NotifTask {
|
|||
$XMLbinding.AppendChild($XMLtext) | Out-Null
|
||||
}
|
||||
|
||||
if ($Body){
|
||||
if ($Body) {
|
||||
# Creation of a group node
|
||||
$XMLgroup = $ToastTemplate.CreateElement("group")
|
||||
$XMLbinding.AppendChild($XMLgroup) | Out-Null
|
||||
|
@ -91,7 +91,7 @@ function Start-NotifTask {
|
|||
$XMLactionAtt1 = $ToastTemplate.CreateAttribute("content")
|
||||
$XMLactionAtt1.Value = $Button1Text
|
||||
$XMLaction.Attributes.Append($XMLactionAtt1) | Out-Null
|
||||
if ($Button1Action){
|
||||
if ($Button1Action) {
|
||||
$XMLactionAtt2 = $ToastTemplate.CreateAttribute("arguments")
|
||||
$XMLactionAtt2.Value = $Button1Action
|
||||
$XMLaction.Attributes.Append($XMLactionAtt2) | Out-Null
|
||||
|
@ -126,7 +126,7 @@ function Start-NotifTask {
|
|||
$ToastTemplate.LastChild.AppendChild($XMLactions) | Out-Null
|
||||
$ToastTemplate.LastChild.AppendChild($XMLtag) | Out-Null
|
||||
|
||||
if ($OnClickAction){
|
||||
if ($OnClickAction) {
|
||||
$ToastTemplate.toast.SetAttribute("activationType", "Protocol") | Out-Null
|
||||
$ToastTemplate.toast.SetAttribute("launch", $OnClickAction) | Out-Null
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to check Black/White List External Path
|
||||
#Function to check Block/Allow List External Path
|
||||
|
||||
function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) {
|
||||
# URL, UNC or Local Path
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to check if modification exists in 'mods' directory
|
||||
#Function to check if modification exists within 'mods' directory
|
||||
|
||||
function Test-Mods ($app) {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to check Mods External Path
|
||||
#Function to check mods External Path
|
||||
|
||||
function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
||||
# URL, UNC or Local Path
|
||||
|
@ -30,7 +30,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
# Collect the external list of href links
|
||||
$BinLinks = $BinResponse.Links | Select-Object -ExpandProperty HREF
|
||||
#If there's a directory path in the HREF:s, delete it (IIS)
|
||||
$CleanBinLinks = $BinLinks -replace "/.*/",""
|
||||
$CleanBinLinks = $BinLinks -replace "/.*/", ""
|
||||
#Modify strings to HREF:s
|
||||
$index = 0
|
||||
foreach ($Bin in $CleanBinLinks) {
|
||||
|
@ -41,14 +41,14 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
}
|
||||
#Delete Local Bins that don't exist Externally
|
||||
$index = 0
|
||||
$CleanLinks = $BinLinks -replace "/.*/",""
|
||||
$CleanLinks = $BinLinks -replace "/.*/", ""
|
||||
foreach ($Bin in $InternalBinsNames) {
|
||||
If ($CleanLinks -notcontains "$Bin") {
|
||||
Remove-Item $LocalMods\bins\$Bin -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
$index++
|
||||
}
|
||||
$CleanBinLinks = $BinLinks -replace "/.*/",""
|
||||
$CleanBinLinks = $BinLinks -replace "/.*/", ""
|
||||
$Bin = ""
|
||||
#Loop through all links
|
||||
$wc = New-Object System.Net.WebClient
|
||||
|
@ -56,7 +56,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
#Check for .exe in listing/HREF:s in an index page pointing to .exe
|
||||
if ($_ -like "*.exe") {
|
||||
$dateExternalBin = ""
|
||||
$dateLocalBin =""
|
||||
$dateLocalBin = ""
|
||||
$wc.OpenRead("$ExternalBins/$_").Close() | Out-Null
|
||||
$dateExternalBin = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss")
|
||||
if (Test-Path -Path $LocalMods"\bins\"$_) {
|
||||
|
@ -64,7 +64,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
}
|
||||
if ($dateExternalBin -gt $dateLocalBin) {
|
||||
$SaveBin = Join-Path -Path "$LocalMods\bins" -ChildPath $_
|
||||
Invoke-WebRequest -Uri "$ExternalBins/$_" -OutFile $SaveBin.Replace("%20"," ") -UseBasicParsing
|
||||
Invoke-WebRequest -Uri "$ExternalBins/$_" -OutFile $SaveBin.Replace("%20", " ") -UseBasicParsing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
$ModLinks = $WebResponse.Links | Select-Object -ExpandProperty HREF
|
||||
|
||||
#If there's a directory path in the HREF:s, delete it (IIS)
|
||||
$CleanLinks = $ModLinks -replace "/.*/",""
|
||||
|
||||
$CleanLinks = $ModLinks -replace "/.*/", ""
|
||||
|
||||
#Modify strings to HREF:s
|
||||
$index = 0
|
||||
foreach ($Mod in $CleanLinks) {
|
||||
|
@ -88,7 +88,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
#Delete Local Mods that don't exist Externally
|
||||
$DeletedMods = 0
|
||||
$index = 0
|
||||
$CleanLinks = $ModLinks -replace "/.*/",""
|
||||
$CleanLinks = $ModLinks -replace "/.*/", ""
|
||||
foreach ($Mod in $InternalModsNames) {
|
||||
If ($CleanLinks -notcontains "$Mod") {
|
||||
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
@ -96,8 +96,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
}
|
||||
$index++
|
||||
}
|
||||
|
||||
$CleanLinks = $ModLinks -replace "/.*/",""
|
||||
|
||||
$CleanLinks = $ModLinks -replace "/.*/", ""
|
||||
|
||||
#Loop through all links
|
||||
$wc = New-Object System.Net.WebClient
|
||||
|
@ -106,13 +106,13 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
if (($_ -like "*.ps1") -or ($_ -like "*.txt")) {
|
||||
try {
|
||||
$dateExternalMod = ""
|
||||
$dateLocalMod =""
|
||||
$dateLocalMod = ""
|
||||
$wc.OpenRead("$ExternalMods/$_").Close() | Out-Null
|
||||
$dateExternalMod = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss")
|
||||
if (Test-Path -Path $LocalMods"\"$_) {
|
||||
$dateLocalMod = (Get-Item "$LocalMods\$_").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
|
||||
if ($dateExternalMod -gt $dateLocalMod) {
|
||||
try {
|
||||
$SaveMod = Join-Path -Path "$LocalMods\" -ChildPath $_
|
||||
|
@ -145,8 +145,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
|
||||
$AZCopySyncOutput = & $WingetUpdatePath\azcopy.exe sync "$AzureBlobSASURL" "$LocalMods" --from-to BlobLocal --delete-destination=true
|
||||
$AZCopyOutputLines = $AZCopySyncOutput.Split([Environment]::NewLine)
|
||||
|
||||
foreach( $_ in $AZCopyOutputLines){
|
||||
|
||||
foreach ( $_ in $AZCopyOutputLines) {
|
||||
$AZCopySyncAdditionsRegex = [regex]::new("(?<=Number of Copy Transfers Completed:\s+)\d+")
|
||||
$AZCopySyncDeletionsRegex = [regex]::new("(?<=Number of Deletions at Destination:\s+)\d+")
|
||||
$AZCopySyncErrorRegex = [regex]::new("^Cannot perform sync due to error:")
|
||||
|
@ -154,15 +154,15 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
$AZCopyAdditions = [int] $AZCopySyncAdditionsRegex.Match($_).Value
|
||||
$AZCopyDeletions = [int] $AZCopySyncDeletionsRegex.Match($_).Value
|
||||
|
||||
if ($AZCopyAdditions -ne 0){
|
||||
if ($AZCopyAdditions -ne 0) {
|
||||
$ModsUpdated = $AZCopyAdditions
|
||||
}
|
||||
|
||||
if ($AZCopyDeletions -ne 0){
|
||||
if ($AZCopyDeletions -ne 0) {
|
||||
$DeletedMods = $AZCopyDeletions
|
||||
}
|
||||
|
||||
if ($AZCopySyncErrorRegex.Match($_).Value){
|
||||
if ($AZCopySyncErrorRegex.Match($_).Value) {
|
||||
Write-Log "AZCopy Sync Error! $_"
|
||||
}
|
||||
}
|
||||
|
@ -179,15 +179,15 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
if (Test-Path -Path $ExternalBins"\*.exe") {
|
||||
$ExternalBinsNames = Get-ChildItem -Path $ExternalBins -Name -Recurse -Include *.exe
|
||||
#Delete Local Bins that don't exist Externally
|
||||
foreach ($Bin in $InternalBinsNames){
|
||||
If ($Bin -notin $ExternalBinsNames ){
|
||||
foreach ($Bin in $InternalBinsNames) {
|
||||
If ($Bin -notin $ExternalBinsNames ) {
|
||||
Remove-Item $LocalMods\bins\$Bin -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
}
|
||||
#Copy newer external bins
|
||||
foreach ($Bin in $ExternalBinsNames){
|
||||
foreach ($Bin in $ExternalBinsNames) {
|
||||
$dateExternalBin = ""
|
||||
$dateLocalBin =""
|
||||
$dateLocalBin = ""
|
||||
if (Test-Path -Path $LocalMods"\bins\"$Bin) {
|
||||
$dateLocalBin = (Get-Item "$LocalMods\bins\$Bin").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
@ -201,20 +201,20 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath, $AzureBlobSASURL) {
|
|||
if ((Test-Path -Path $ExternalMods"\*.ps1") -or (Test-Path -Path $ExternalMods"\*.txt")) {
|
||||
#Get File Names Externally
|
||||
$ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1, *.txt
|
||||
|
||||
|
||||
#Delete Local Mods that don't exist Externally
|
||||
$DeletedMods = 0
|
||||
foreach ($Mod in $InternalModsNames){
|
||||
If ($Mod -notin $ExternalModsNames ){
|
||||
foreach ($Mod in $InternalModsNames) {
|
||||
If ($Mod -notin $ExternalModsNames ) {
|
||||
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$DeletedMods++
|
||||
}
|
||||
}
|
||||
|
||||
#Copy newer external mods
|
||||
foreach ($Mod in $ExternalModsNames){
|
||||
foreach ($Mod in $ExternalModsNames) {
|
||||
$dateExternalMod = ""
|
||||
$dateLocalMod =""
|
||||
$dateLocalMod = ""
|
||||
if (Test-Path -Path $LocalMods"\"$Mod) {
|
||||
$dateLocalMod = (Get-Item "$LocalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to check connectivity
|
||||
#Function to check the connectivity
|
||||
|
||||
function Test-Network {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to check if there's a Pending Reboot
|
||||
#Function to check if there is a Pending Reboot
|
||||
|
||||
function Test-PendingReboot {
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#Function to Update an App
|
||||
#Function to update an App
|
||||
|
||||
Function Update-App ($app) {
|
||||
|
||||
#Get App Info
|
||||
$ReleaseNoteURL = Get-AppInfo $app.Id
|
||||
if ($ReleaseNoteURL){
|
||||
if ($ReleaseNoteURL) {
|
||||
$Button1Text = $NotifLocale.local.outputs.output[10].message
|
||||
}
|
||||
|
||||
|
@ -30,11 +30,11 @@ Function Update-App ($app) {
|
|||
|
||||
#Run Winget Upgrade command
|
||||
if ($ModsOverride) {
|
||||
Write-Log "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride"
|
||||
Write-Log "-> 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
|
||||
}
|
||||
else {
|
||||
Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
|
||||
Write-Log "-> 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
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,13 @@ Function Update-App ($app) {
|
|||
|
||||
#If app failed to upgrade, run Install command
|
||||
Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow"
|
||||
|
||||
|
||||
if ($ModsOverride) {
|
||||
Write-Log "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride"
|
||||
Write-Log "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride"
|
||||
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append
|
||||
}
|
||||
else {
|
||||
Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
|
||||
Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
|
||||
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Function to Update WAU
|
||||
#Function to update WAU
|
||||
|
||||
function Update-WAU {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Write Log Function
|
||||
#Write to Log Function
|
||||
|
||||
function Write-Log ($LogMsg, $LogColor = "White") {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<# ARRAYS/VARIABLES #>
|
||||
#App to Run (as SYSTEM)
|
||||
#$RunWait = $False if it shouldn't be waited for completion. Example:
|
||||
#$RunWait = $False if it shouldn't be waited for completion. For example:
|
||||
#$RunSystem = "$PSScriptRoot\bins\MsiZap.exe"
|
||||
#$RunSwitch = "tw! {GUID}"
|
||||
$RunSystem = ""
|
||||
|
|
|
@ -1,61 +1,56 @@
|
|||
#Common shared functions for mods handling
|
||||
#Common shared functions to handle the mods
|
||||
|
||||
function Invoke-ModsApp ($Run, $RunSwitch, $RunWait, $User) {
|
||||
if (Test-Path "$Run") {
|
||||
if (!$RunSwitch) {$RunSwitch = " "}
|
||||
if (!$User) {
|
||||
if (!$RunWait) {
|
||||
Start-Process $Run -ArgumentList $RunSwitch
|
||||
}
|
||||
else {
|
||||
Start-Process $Run -ArgumentList $RunSwitch -Wait
|
||||
}
|
||||
}
|
||||
else {
|
||||
Start-Process explorer $Run
|
||||
}
|
||||
if (!$RunSwitch) { $RunSwitch = " " }
|
||||
if (!$User) {
|
||||
if (!$RunWait) {
|
||||
Start-Process $Run -ArgumentList $RunSwitch
|
||||
}
|
||||
else {
|
||||
Start-Process $Run -ArgumentList $RunSwitch -Wait
|
||||
}
|
||||
}
|
||||
else {
|
||||
Start-Process explorer $Run
|
||||
}
|
||||
}
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
function Stop-ModsProc ($Proc) {
|
||||
foreach ($process in $Proc)
|
||||
{
|
||||
foreach ($process in $Proc) {
|
||||
Stop-Process -Name $process -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
Return
|
||||
}
|
||||
|
||||
function Wait-ModsProc ($Wait) {
|
||||
foreach ($process in $Wait)
|
||||
{
|
||||
foreach ($process in $Wait) {
|
||||
Get-Process $process -ErrorAction SilentlyContinue | Foreach-Object { $_.WaitForExit() }
|
||||
}
|
||||
Return
|
||||
}
|
||||
|
||||
function Install-WingetID ($WingetIDInst) {
|
||||
foreach ($app in $WingetIDInst)
|
||||
{
|
||||
foreach ($app in $WingetIDInst) {
|
||||
& $Winget install --id $app --accept-package-agreements --accept-source-agreements -h
|
||||
}
|
||||
Return
|
||||
}
|
||||
|
||||
function Uninstall-WingetID ($WingetIDUninst) {
|
||||
foreach ($app in $WingetIDUninst)
|
||||
{
|
||||
foreach ($app in $WingetIDUninst) {
|
||||
& $Winget uninstall --id $app -e --accept-source-agreements -h
|
||||
}
|
||||
Return
|
||||
}
|
||||
|
||||
function Uninstall-ModsApp ($AppUninst) {
|
||||
foreach ($app in $AppUninst)
|
||||
{
|
||||
foreach ($app in $AppUninst) {
|
||||
$InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||
foreach ($obj in $InstalledSoftware){
|
||||
foreach ($obj in $InstalledSoftware) {
|
||||
if ($obj.GetValue('DisplayName') -like $App) {
|
||||
$UninstallString = $obj.GetValue('UninstallString')
|
||||
$CleanedUninstallString = $UninstallString.Trim([char]0x0022)
|
||||
|
@ -111,7 +106,7 @@ function Uninstall-ModsApp ($AppUninst) {
|
|||
}
|
||||
if (!$x64) {
|
||||
$InstalledSoftware = Get-ChildItem "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||
foreach ($obj in $InstalledSoftware){
|
||||
foreach ($obj in $InstalledSoftware) {
|
||||
if ($obj.GetValue('DisplayName') -like $App) {
|
||||
$UninstallString = $obj.GetValue('UninstallString')
|
||||
$CleanedUninstallString = $UninstallString.Trim([char]0x0022)
|
||||
|
@ -169,8 +164,7 @@ function Uninstall-ModsApp ($AppUninst) {
|
|||
Return
|
||||
}
|
||||
function Remove-ModsLnk ($Lnk) {
|
||||
foreach ($link in $Lnk)
|
||||
{
|
||||
foreach ($link in $Lnk) {
|
||||
Remove-Item -Path "${env:Public}\Desktop\$link.lnk" -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
Return
|
||||
|
@ -178,7 +172,7 @@ function Remove-ModsLnk ($Lnk) {
|
|||
|
||||
function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) {
|
||||
if ($AddKey -like "HKEY_LOCAL_MACHINE*") {
|
||||
$AddKey = $AddKey.replace("HKEY_LOCAL_MACHINE","HKLM:")
|
||||
$AddKey = $AddKey.replace("HKEY_LOCAL_MACHINE", "HKLM:")
|
||||
}
|
||||
if (!(Test-Path "$AddKey")) {
|
||||
New-Item $AddKey -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
@ -189,7 +183,7 @@ function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) {
|
|||
|
||||
function Remove-ModsReg ($DelKey, $DelValue) {
|
||||
if ($DelKey -like "HKEY_LOCAL_MACHINE*") {
|
||||
$DelKey = $DelKey.replace("HKEY_LOCAL_MACHINE","HKLM:")
|
||||
$DelKey = $DelKey.replace("HKEY_LOCAL_MACHINE", "HKLM:")
|
||||
}
|
||||
if (Test-Path "$DelKey") {
|
||||
if (!$DelValue) {
|
||||
|
@ -203,8 +197,7 @@ function Remove-ModsReg ($DelKey, $DelValue) {
|
|||
}
|
||||
|
||||
function Remove-ModsFile ($DelFile) {
|
||||
foreach ($file in $DelFile)
|
||||
{
|
||||
foreach ($file in $DelFile) {
|
||||
if (Test-Path "$file") {
|
||||
Remove-Item -Path $file -Force -Recurse -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
|
@ -228,14 +221,13 @@ function Copy-ModsFile ($CopyFile, $CopyTo) {
|
|||
|
||||
function Edit-ModsFile ($File, $FindText, $ReplaceText) {
|
||||
if (Test-Path "$File") {
|
||||
((Get-Content -path $File -Raw) -replace "$FindText","$ReplaceText") | Set-Content -Path $File -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
((Get-Content -path $File -Raw) -replace "$FindText", "$ReplaceText") | Set-Content -Path $File -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
Return
|
||||
}
|
||||
|
||||
function Grant-ModsPath ($GrantPath) {
|
||||
foreach ($path in $GrantPath)
|
||||
{
|
||||
foreach ($path in $GrantPath) {
|
||||
if (Test-Path "$path") {
|
||||
$NewAcl = Get-Acl -Path $path
|
||||
$identity = New-Object System.Security.Principal.SecurityIdentifier S-1-5-11
|
||||
|
|
Loading…
Reference in New Issue