CLS #------------------------------- 2016 Server ----------------------------------- # Set Counters for Loop for Each Month of the Year # Run after Patch Tuesday "----2016 Server ----" | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' $X=1 $MaxCounter=Get-Date -Format "MM" Do{ # Instnatiate Array $Lines=@() if($X -lt 10){ # Get Webpage Data (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-0$x Cumulative Update for Windows Server 2016 for x64-based Systems").Content | Out-File C:\temp\2016-$X.txt }Else{ (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-$x Cumulative Update for Windows Server 2016 for x64-based Systems").Content | Out-File C:\temp\2016-$X.txt } #Export Data Out to File $Lines= Get-Content C:\temp\2016-$X.txt #Loop Through Each File to Get KB Output Foreach($Line in $Lines){ If($Line -like "*(KB*"){$Line.Trim() | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' -Append} } #Incriment Counter $x=$X+1 }While($x -le $MaxCounter) #------------------------------- 2019 Server ----------------------------------- "----2019 Server ----" | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' -Append $X=1 Do{ # Instnatiate Array $Lines=@() if($X -lt 10){ # Get Webpage Data (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-0$x Cumulative Update for Windows Server 2019 for x64-based Systems").Content | Out-File C:\temp\2019-$X.txt }Else{ (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-$x Cumulative Update for Windows Server 2019 for x64-based Systems").Content | Out-File C:\temp\2019-$X.txt } #Export Data Out to File $Lines= Get-Content C:\temp\2019-$X.txt #Loop Through Each File to Get KB Output Foreach($Line in $Lines){ If($Line -like "*(KB*"){$Line.Trim() | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' -Append} } #Incriment Counter $x=$X+1 }While($x -le $MaxCounter) #------------------------------- 2022 Server ----------------------------------- "----2022 Server ----" | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' -Append $X=1 Do{ # Instnatiate Array $Lines=@() if($X -lt 10){ # Get Webpage Data (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-0$X Cumulative Update for Microsoft server operating system version 21H2 for x64-based Systems").Content | Out-File C:\temp\2022-$X.txt }Else{ # Get Webpage Data (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-$X Cumulative Update for Microsoft server operating system version 21H2 for x64-based Systems").Content | Out-File C:\temp\2022-$X.txt } #Export Data Out to File $Lines= Get-Content C:\temp\2022-$X.txt #Loop Through Each File to Get KB Output Foreach($Line in $Lines){ If($Line -like "*(KB*"){$Line.Trim() | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' -Append} } #Incriment Counter $x=$X+1 }While($x -le $MaxCounter) #------------------------------- 2025 Server ----------------------------------- "----2025 Server ----" | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' -Append $X=1 Do{ # Instnatiate Array $Lines=@() if($X -lt 10){ # Get Webpage Data (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-0$X Cumulative Update for Microsoft server operating system version 24H2 for x64-based Systems").Content | Out-File C:\temp\2025-$X.txt }Else{ # Get Webpage Data (Invoke-WebRequest -Uri "https://www.catalog.update.microsoft.com/Search.aspx?q=2025-$X Cumulative Update for Microsoft server operating system version 24H2 for x64-based Systems").Content | Out-File C:\temp\2025-$X.txt } #Export Data Out to File $Lines= Get-Content C:\temp\2025-$X.txt #Loop Through Each File to Get KB Output Foreach($Line in $Lines){ If($Line -like "*(KB*"){$Line.Trim() | Tee-Object 'C:\temp\Windows_Monthly_Rollups.txt' -Append} } #Incriment Counter $x=$X+1 }While($x -le $MaxCounter)