Add files via upload

pull/2/head
Romanitho 2022-01-18 09:49:48 +01:00 committed by GitHub
parent 2cb2d5d3ae
commit 448bc1f2dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 19 deletions

View File

@ -60,8 +60,8 @@ function Test-Network {
Write-Log "Checking internet connection..." "Yellow" Write-Log "Checking internet connection..." "Yellow"
while (!$ping -and $timeout -lt 1800){ while (!$ping -and $timeout -lt 1800){
try{ try{
Invoke-RestMethod -Uri "https://ifconfig.me/" Invoke-RestMethod -Uri 'https://en.wikipedia.org/api/rest_v1/'
Write-Log "Connected !" "Green" Write-Log "Coonected !" "Green"
$ping = $true $ping = $true
return return
} }
@ -74,7 +74,7 @@ function Test-Network {
#Send Notif if no connection for 5 min #Send Notif if no connection for 5 min
Write-Log "Notify 'No connection'" "Yellow" Write-Log "Notify 'No connection'" "Yellow"
$Title = "Vérifiez votre connexion réseau" $Title = "Vérifiez votre connexion réseau"
$Message = "Impossible de vérifier les mises à jour logicielles pour le moment !" $Message = "Impossible de vérifier les mises à jours logicielles pour le moment !"
$MessageType = "warning" $MessageType = "warning"
$Balise = "connection" $Balise = "connection"
Run-NotifTask $Title $Message $MessageType $Balise Run-NotifTask $Title $Message $MessageType $Balise
@ -105,11 +105,8 @@ function Get-WingetOutdated {
Write-Log "No Winget installed !" Write-Log "No Winget installed !"
return return
} }
#Accept sources
& $upgradecmd upgrade * --accept-source-agreements | Out-Null & $upgradecmd upgrade * --accept-source-agreements | Out-Null
#List updates
$upgradeResult = & $upgradecmd upgrade | Out-String $upgradeResult = & $upgradecmd upgrade | Out-String
if (!($upgradeResult -match "-----")){ if (!($upgradeResult -match "-----")){
@ -160,26 +157,26 @@ function Get-WingetOutdated {
return $upgradeList return $upgradeList
} }
function Get-ExcludedApps{
if (Test-Path "$WorkingDir\excluded_apps.txt"){
return Get-Content -Path "$WorkingDir\excluded_apps.txt"
}
}
### MAIN ### ### MAIN ###
#Run initialisation #Run initialisation
Init Init
#Exclude apps (auto update)
$toSkip = @(
"Google.Chrome",
"Mozilla.Firefox",
"Mozilla.Firefox.ESR",
"Microsoft.Edge",
"Microsoft.Office"
)
#Check network connectivity #Check network connectivity
$ping = Test-Network $ping = Test-Network
if ($ping){ if ($ping){
#Get outdated choco packages #Exclude apps (auto update)
$toSkip = Get-ExcludedApps
#Get outdated packages
Write-Log "Checking available updates..." "yellow" Write-Log "Checking available updates..." "yellow"
#Get outdated apps #Get outdated apps
@ -217,7 +214,7 @@ if ($ping){
$Log | out-file -filepath $LogFile -Append $Log | out-file -filepath $LogFile -Append
#Winget upgrade #Winget upgrade
& $upgradecmd upgrade -e --id $($app.Id) --accept-package-agreements --accept-source-agreements & $upgradecmd upgrade -e --id $($app.Id) --accept-package-agreements --accept-source-agreements -h -o "$LogFile"
Sleep 3 Sleep 3
$Log = "#--- Winget - $($app.Name) Upgrade Finished ---" $Log = "#--- Winget - $($app.Name) Upgrade Finished ---"
@ -280,4 +277,4 @@ else{
$Balise = "connection" $Balise = "connection"
Run-NotifTask $Title $Message $MessageType $Balise Run-NotifTask $Title $Message $MessageType $Balise
} }
Write-Log "End of process!" "Cyan" Write-Log "End of process!" "Cyan"