stefan007
Goto Top

WSUS Konfiguration - Updates sofort laden und installieren wenn VM eingeschaltet wird

Hi Leute,

ich möchte gerne wissen, ob es möglich ist, dass der WSUS (Vers. 2012R2) bzw. die dazugehörige GPO so konfiguriert werden kann, dass eingeschaltete VMs direkt die Updates (nach dem Hochfahren, ggf. auch ohne Windows Anmeldung) laden und installieren?

Hintergrund:
Ich habe hier ein Testlab mit 10 VMs auf einem HV-Core 2016. Die Betriebssysteme sind von 2012R2 bis 2019 vertreten. Um Zeit zu sparen möchte ich gerne die VMs so konfigurieren, dass die Updates dann eigenständig installiert werden (sollten face-smile ). Ein eigenständiger Reboot ist in dem Falle nicht zwingend notwendig.


Gruß,

Stefan

Content-Key: 475766

Url: https://administrator.de/contentid/475766

Printed on: April 19, 2024 at 00:04 o'clock

Member: XN04113
Solution XN04113 Jul 20, 2019 updated at 11:12:05 (UTC)
Goto Top
einfach ein kleines Powershell Script als Startup Task einrichten, mache ich seit Jahren für Testclients so

$ServiceName = "wuauserv"  
$count = 1
$maxcount = 10
$sleeptime = 30

$Criteria = "IsInstalled=0 and Type='Software'"  

$year = Get-Date -UFormat %Y
$month = Get-Date -UFormat %m
$day = Get-Date -UFormat %d

$sLogPath = "C:\LogFiles"  
$sLogName = "WSUSrun" + ".log"  
$sLogFile = $sLogPath + "\" + $sLogName  

#*****************************************************************************
Function LogWrite
{
	Param ([string]$sLogString)
	
	$time = Get-Date -UFormat %T
	$sLogString = $day + "." + $month + "." + $year + " - " + $time + " * " + $sLogString  
	write-host $sLogString
	Add-content $sLogFile -value $sLogString
}
#*****************************************************************************

$string = "--- START ---"  
LogWrite $string

$arrService = Get-Service -Name $ServiceName
if ($arrService.Status -ne "Running") {  
    $string = "service " + $ServiceName + " not running, starting service..."  
    LogWrite $string
    Start-Service $ServiceName
}

Do {
    $string = "checking service, attempt " + $count  
    LogWrite $string
    $arrService = Get-Service -Name $ServiceName
    if ($arrService.Status -ne "Running")  
    {
        $string = "service not running, sleeping " + $sleeptime + " seconds..."  
        LogWrite $string
        Start-Sleep $sleeptime
        $count++
    }
    else
    {
        $string = "service running, final sleep for " + $sleeptime + " seconds..."  
        LogWrite $string
        Start-Sleep $sleeptime
        break
    }
} while ($count -le $maxcount)

If ($count -gt $maxcount) {
    $string = "service not running, exitcode 1"  
    LogWrite $string
    Exit 1
}

LogWrite "Creating update session"  
$Session = New-Object -com "Microsoft.Update.Session"  

LogWrite "Searching for updates..."  
$Search = $Session.CreateUpdateSearcher()
$SearchResult = $Search.Search($Criteria)
$string = "There are " + $SearchResult.Updates.Count + " updates available"  
LogWrite $string

$AvailableUpdates = $SearchResult.Updates 

if($AvailableUpdates.Count -lt 1) {
    LogWrite "No results meet your criteria, disabling scheduled task."  
    Disable-ScheduledTask -TaskName "WSUSrun"  
    exit 0
}

LogWrite "Updates selected for installation"  
$AvailableUpdates | ForEach-Object {
    $string = "- " + $_.Title  
    LogWrite $string
    $_.Categories | ForEach-Object {
        $string = "  # category: " + $_.Name.ToString()  
        LogWrite $string
    }
}

LogWrite "Creating download selection"  
$DownloadCollection = New-Object -com "Microsoft.Update.UpdateColl"  

$AvailableUpdates | ForEach-Object {
    if ($_.InstallationBehavior.CanRequestUserInput -ne $TRUE) {
        $DownloadCollection.Add($_) | Out-Null
    }
}

LogWrite "Downloading updates..."  
$Downloader = $Session.CreateUpdateDownloader() 
$Downloader.Updates = $DownloadCollection 
$DownloadResult = $Downloader.Download() 
LogWrite "Download complete"   

LogWrite "Creating installation object"  
$InstallCollection = New-Object -com "Microsoft.Update.UpdateColl"  
$AvailableUpdates | ForEach-Object {
    if ($_.IsDownloaded) {
        $InstallCollection.Add($_) | Out-Null
    }
}

LogWrite "Installing updates..."  
$Installer = $Session.CreateUpdateInstaller()
$Installer.Updates = $InstallCollection
$InstallResult = $Installer.Install()
LogWrite "Installation complete"  

if ($InstallResult.RebootRequired) {
    LogWrite "Rebooting..."  
    Restart-Computer -Computer localhost -Force
}
else {
    LogWrite "No reboot required, scheduled task disabled"  
    Disable-ScheduledTask -TaskName "WSUSrun"  
	Invoke-Command { wuauclt.exe /detectnow /reportnow}
}

exit 0
Member: DerWoWusste
Solution DerWoWusste Jul 20, 2019 at 17:17:41 (UTC)
Goto Top
Wuinstall /install
Ins Startskript.

Wuinstall laden Von https://web.archive.org/web/20151227002916/http://www.hs2n.at/component/ ...