aaa
This commit is contained in:
24
setup.py
24
setup.py
@@ -8,29 +8,9 @@ day_reboot = 'SUN'
|
||||
def install():
|
||||
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():
|
||||
hostnames = ["localhost"]
|
||||
reboot_pending = check_reboot_pending(hostnames)
|
||||
print(reboot_pending)
|
||||
if reboot_pending is True:
|
||||
print(f"Le poste a un reboot en attente.")
|
||||
if reg_key_exists(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'):
|
||||
print("Une mise à jour necéssite un redémarrage")
|
||||
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"')
|
||||
return "WARNING"
|
||||
|
||||
Reference in New Issue
Block a user