Abfrage, ob Installation abgeschlossen ist

Antworten
djfelix
Beiträge: 5
Registriert: 23 Sep 2020, 23:52

Abfrage, ob Installation abgeschlossen ist

Beitrag von djfelix »

Hallo,

ich baue gerade im Homelab ein kleines OPSI-Testnetz und bin generell noch etwas neu mit OPSI.

Mein aktueller Plan:
Windows soll (per PowerShell-Skript) herunterfahren, falls sich kein Benutzer innerhalb von X Minuten anmeldet, allerdings darf eine (De-)Installation von OPSI dadurch nicht unterbrochen werden.

Gibt es eine Möglichkeit, den aktuellen Status des OPSI-Clients abzufragen?
Idee: Während der Installation wird (meistens) das Schloss oben rechts angezeigt und die Anmeldung gesperrt/verhindert. Kann man diesen Zustand aus OPSI abfragen?

Vielen Dank
djfelix
Beiträge: 5
Registriert: 23 Sep 2020, 23:52

Re: Abfrage, ob Installation abgeschlossen ist

Beitrag von djfelix »

Hier mal mein aktuelles Skript:

Code: Alles auswählen

# Check if user is logged in
$notloggedin = [String]::IsNullOrEmpty((Get-CimInstance win32_computersystem | Select-Object -ExpandProperty username))

# Check if Microsoft-Update is busy
$busy = new-object -com Microsoft.update.Installer
$notbusy = -not($busy.isBusy)

# Check if OPSI is configuring software
$opsinotinstalling = true       # This will ignore OPSI!

# Check if automated shutdown is required
if ($notloggedin -and $notbusy -and $opsinotinstalling) {
    Write-Output "Automated shutdown is required and will be executed now!"
    Write-Output "Shutdown in..."
    for ($i=10; $i -gt 0; $i--) {
        Write-Output $i
        Start-Sleep 2
    }
    Stop-Computer -ComputerName localhost
}
Relativ einfach, aber mMn sehr hilfreich (im Moment ignoriert es aber den Status von OPSI, oder Softwareinstallationen im Allgemeinen). Ausgeführt wird es nachdem der PC einige Zeit inaktiv ist (GPO -> Aufgabenplanung).

Ab wann genau zählt ein PC als "inaktiv"? Zählt ein PC wärend OPSI läuft auch als "aktiv", oder wird das nur über Mausbewegungen/Tastatureingaben bestimmt?
Antworten