aaa
This commit is contained in:
24
setup.py
24
setup.py
@@ -8,29 +8,9 @@ day_reboot = 'SUN'
|
|||||||
def install():
|
def install():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def check_reboot_pending(hostname):
|
|
||||||
"""
|
|
||||||
Fonction pour vérifier si un poste a un reboot en attente.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
hostname: Le nom d'hôte du poste à vérifier.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
True si un reboot est en attente, False sinon.
|
|
||||||
"""
|
|
||||||
returncode = run('systeminfo | find "Restart"',accept_returncodes=[0, 1, 3010])
|
|
||||||
|
|
||||||
if returncode:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def audit():
|
def audit():
|
||||||
hostnames = ["localhost"]
|
if reg_key_exists(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'):
|
||||||
reboot_pending = check_reboot_pending(hostnames)
|
print("Une mise à jour necéssite un redémarrage")
|
||||||
print(reboot_pending)
|
|
||||||
if reboot_pending is True:
|
|
||||||
print(f"Le poste a un reboot en attente.")
|
|
||||||
WAPT.write_audit_data_if_changed("Update Reboot", "Reboot Pending", reboot_pending)
|
WAPT.write_audit_data_if_changed("Update Reboot", "Reboot Pending", reboot_pending)
|
||||||
run(f'schtasks /create /sc weekly /st {hour_reboot} /RU "NT AUTHORITY\SYSTEM" /d {day_reboot} /tn "Reboot_Update" /tr "shutdown /r /t 0"')
|
run(f'schtasks /create /sc weekly /st {hour_reboot} /RU "NT AUTHORITY\SYSTEM" /d {day_reboot} /tn "Reboot_Update" /tr "shutdown /r /t 0"')
|
||||||
return "WARNING"
|
return "WARNING"
|
||||||
|
|||||||
Reference in New Issue
Block a user