Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

Connaitre l'état du support des versions de windows depuis MS web "release-information":

Publié le par damcuvelier

$erroractionpreference = 'silentlycontinue'
set-executionpolicy bypass -force
$scriptpath = split-path -parent $MyInvocation.MyCommand.Path

$url = "https://learn.microsoft.com/fr-fr/windows/release-health/release-information"
$response = Invoke-WebRequest $url
$content = $response.Content

function getversion($table){
    $index = '<h4 id="' + $table + '">'
# Recherche du tableau de maintenance
$tableStart = $content.IndexOf($index)
$tableEnd = $content.IndexOf('</table>', $tableStart)
$tableHtml = $content.Substring($tableStart, $tableEnd - $tableStart + 8)

$regex = '(?<=<td>)(.*?)(?=<\/td>)'
$matches = [regex]::Matches($tableHtml, $regex)
$version = $matches[0].Value
return $version
}


$outfile = "$scriptpath\Findemaintenance.txt"
$outfile2 = "$scriptpath\Findemaintenance2.txt"
$outfile3 = "$scriptpath\Findemaintenance3.txt" 
cls

$regex = '(?<=<summary>).*?(?=</summary>)'

$matches = [regex]::Matches($response, $regex, 'Singleline')
foreach ($match in $matches) {
    $match.Value | out-file $outfile -Append -Encoding ascii -Force
}

(Get-Content -Path $outfile -Raw) -replace "`r`n", "" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2 -Raw) -replace "`r`n", "" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2 -Raw) -replace "`r", "" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2 -Raw) -replace "`n", "" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2 -Raw) -replace "<\/strong> - Fin de maintenance", " - Fin de maintenance<>" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2 -Raw) -replace "<\/strong>", "`r`n" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2 -Raw) -replace "<>", "`r`n" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2 -Raw) -replace "<strong>", "" | Set-Content -Path $outfile2
# (Get-Content -Path $outfile2 -Raw) -replace ":", ":`r`n" | Set-Content -Path $outfile2
(Get-Content -Path $outfile2) | foreach{if($_ -match "Fin de maintenance"){$_ | out-file $outfile3 -Append -Encoding ascii -Force}}
(Get-Content -Path $outfile3 -Raw) -replace " - Fin de maintenance", "" | Set-Content -Path $outfile3
(Get-Content -Path $outfile3 -Raw) -replace "`r`n", ";" | Set-Content -Path $outfile3

$Findemaintenances = ""
Get-Content -Path $outfile3 | foreach{$Findemaintenances +=$_}
cmd /c "del /F /Q $outfile"
cmd /c "del /F /Q $outfile2"
cmd /c "del /F /Q $outfile3"


$maintenance = getversion("canal-de-maintenance")
$lastversionmaintenance = "Derniere version Canal de maintenance: $maintenance"

$LTSB = getversion("éditions-ltsbltsc-entreprise-et-iotentreprise")
$lastversionLTSB = "Derniere version Editions LTSB/LTSC Entreprise et IoT Entreprise: $LTSB"

# $Findemaintenance += $Findemaintenances.split(";") + "`n"
$Findemaintenance = $Findemaintenances.replace(";","`r`n ")
$lastFindemaintenances = "Version qui sont en fin de maintenance sur le Canal Principal de maintenance: `r`n $Findemaintenance"

write-host " $lastversionmaintenance `n $lastversionLTSB `n $lastFindemaintenances"
 

Commenter cet article