Update Windows / Clear Netstack
Paste the following Script into a Admin Powershell Window (Press windows logo key + X, then Press "A") PASTE:
⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
Write-Host "Blactec.biz IT Consultation"
sfc /scannow
dism /Online /Cleanup-image /Restorehealth
Install-Module PSWindowsUpdate
Get-WindowsUpdate
Install-WindowsUpdate
Get-Command –module PSWindowsUpdate
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d
Get-WUInstall –MicrosoftUpdate –AcceptAll
-Confirm:$false
Set-ExecutionPolicy unrestricted
ipconfig /release
ipconfig /renew
ipconfig /flushdns
ipconfig /registerdns
netsh winsock reset
powershell "(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey"
$TempFileLocation = "$env:windir\Temp","$env:TEMP"
$SoftwareDistributionLocation = "$env:windir\SoftwareDistribution\Download"
$TempFile = Get-ChildItem $TempFileLocation -Recurse
$TempFileCount = ($TempFile).count
if($TempFileCount -eq "0") {
Write-Host "There are no files in the folder $TempFileLocation" -ForegroundColor Green
}
Else {
$TempFile | Remove-Item -Confirm:$false -Recurse -Force -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
Write-Host "Cleared $TempFileCount files in the folder $TempFileLocation" -ForegroundColor Green
}
$SoftwareDistribution = Get-ChildItem $SoftwareDistributionLocation -Recurse
$SoftwareDistributionCount = ($SoftwareDistribution).Count
if($SoftwareDistributionCount -eq "0"){
Write-Host " There are no files in the folder $SoftwareDistributionLocation" -ForegroundColor Green
}
Else
{
$SoftwareDistribution | Remove-Item -Confirm:$false -Recurse -Force -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
Write-Host "Cleared $SoftwareDistributionCount files in the folder $SoftwareDistributionLocation" -ForegroundColor Green
}
$ErrorActionPreference = "SilentlyContinue"
If ($Error) {
$Error.Clear()
}
$Today = Get-Date
$UpdateCollection = New-Object -ComObject Microsoft.Update.UpdateColl
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
$Session = New-Object -ComObject Microsoft.Update.Session
Write-Host "Blactec.biz got you working right? Now You know the Business"
Write-Host "`t Initialising and Checking for Applicable Updates. Please wait ..." -ForeGroundColor "Yellow"
$Result = $Searcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
If ($Result.Updates.Count -EQ 0) {
Write-Host "`t There are no applicable updates for this computer."
}
Else {
$ReportFile = $Env:ComputerName + "_Report.txt"
If (Test-Path $ReportFile) {
Remove-Item $ReportFile
}
New-Item $ReportFile -Type File -Force -Value "Windows Update Report For Computer: $Env:ComputerName`r`n" | Out-Null
Add-Content $ReportFile "Report Created On: $Today`r"
Add-Content $ReportFile "==============================================================================`r`n"
Write-Host "`t Preparing List of Applicable Updates For This Computer ..." -ForeGroundColor "Yellow"
Add-Content $ReportFile "List of Applicable Updates For This Computer`r"
Add-Content $ReportFile "------------------------------------------------`r"
For ($Counter = 0; $Counter -LT $Result.Updates.Count; $Counter++) {
$DisplayCount = $Counter + 1
$Update = $Result.Updates.Item($Counter)
$UpdateTitle = $Update.Title
Add-Content $ReportFile "`t $DisplayCount -- $UpdateTitle"
}
$Counter = 0
$DisplayCount = 0
Add-Content $ReportFile "`r`n"
Write-Host "`t Initialising Download of Applicable Updates ..." -ForegroundColor "Yellow"
Add-Content $ReportFile "Initialising Download of Applicable Updates"
Add-Content $ReportFile "------------------------------------------------`r"
$Downloader = $Session.CreateUpdateDownloader()
$UpdatesList = $Result.Updates
For ($Counter = 0; $Counter -LT $Result.Updates.Count; $Counter++) {
$UpdateCollection.Add($UpdatesList.Item($Counter)) | Out-Null
$ShowThis = $UpdatesList.Item($Counter).Title
$DisplayCount = $Counter + 1
Add-Content $ReportFile "`t $DisplayCount -- Downloading Update $ShowThis `r"
$Downloader.Updates = $UpdateCollection
$Track = $Downloader.Download()
If (($Track.HResult -EQ 0) -AND ($Track.ResultCode -EQ 2)) {
Add-Content $ReportFile "`t Download Status: SUCCESS"
}
Else {
Add-Content $ReportFile "`t Download Status: FAILED With Error -- $Error()"
$Error.Clear()
Add-content $ReportFile "`r"
}
}
$Counter = 0
$DisplayCount = 0
Write-Host "`t Starting Installation of Downloaded Updates ..." -ForegroundColor "Yellow"
Add-Content $ReportFile "`r`n"
Get-WmiObject
Add-Content $ReportFile "Installation of Downloaded Updates"
Add-Content $ReportFile "------------------------------------------------`r"
$Installer = New-Object -ComObject Microsoft.Update.Installer
For ($Counter = 0; $Counter -LT $UpdateCollection.Count; $Counter++) {
$Track = $Null
$DisplayCount = $Counter + 1
$WriteThis = $UpdateCollection.Item($Counter).Title
Add-Content $ReportFile "`t $DisplayCount -- Installing Update: $WriteThis"
$Installer.Updates = $UpdateCollection
Try {
$Track = $Installer.Install()
Add-Content $ReportFile "`t Update Installation Status: SUCCESS"
}
Catch {
[System.Exception]
Add-Content $ReportFile "`t Update Installation Status: FAILED With Error -- $Error()"
$Error.Clear()
Add-content $ReportFile "`r"
}
}
}
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $exchangeSession -DisableNameChecking
Shutdown -r -f -t 3