$downloadsFolder = "$env:userprofile\Downloads"
$exeFiles = Get-ChildItem -Path $downloadsFolder -Filter *.exe
$msuFiles = Get-ChildItem -Path $downloadsFolder -Filter *.msu

foreach ($file in $exeFiles) {
    $program = Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object {$_.DisplayName -eq $file.BaseName}
    if ($program -eq $null) {
        Start-Process -FilePath $file.FullName -ArgumentList "/quiet"
        Write-Host "Installed $($file.Name)"
    } else {
        Write-Host "$($file.Name) is already installed"
    }
}

foreach ($file in $msuFiles) {
    $update = Get-HotFix | Where-Object {$_.HotFixID -eq $file.BaseName}
    if ($update -eq $null) {
        $kbNumber = $file.BaseName -replace 'KB',''
        $kbRegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_for_KB$kbNumber~*~*~*"
        $kbPackage = Get-Item $kbRegKey -ErrorAction SilentlyContinue
        if ($kbPackage -ne $null) {
            Start-Process -FilePath "dism.exe" -ArgumentList "/Online", "/Add-Package", "/PackagePath:$($file.FullName)", "/Quiet", "/NoRestart"
            Write-Host "Installed $($file.Name)"
        } else {
            Write-Host "$($file.Name) is already installed"
        }
    } else {
        Write-Host "$($file.Name) is already installed"
    }
}
