CmdLets/Install-WindowsUpdates.ps1

Function Install-WindowsUpdates 
 {

    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$True)]$Updates,
        [Parameter(Mandatory=$True)]$Session
    )
    $Reboot = $False
    $Installer = $Session.CreateUpdateInstaller()
    $Updates | ForEach-Object {
        $i++
        $UpdatesToInstall = New-Object -Com Microsoft.Update.UpdateColl
        if ($_.isdownloaded -and $_.Title -NotLike "*Feature Update*") {
            Write-Host "Installing update $i of $($Updates.Count()): $($_.Title)"
            $UpdatesToInstall.Add($_) | out-null
            $Installer.Updates = $UpdatesToInstall
            $Result = $Installer.Install()
            if ($Result.RebootRequired) { 
                $Reboot = $true 
            }
        }
    }
    $Reboot

}