Skip to content

Network Security Script: Check Windows System Updates Remotely

To check if any computer in the network is outdated and needs an update, you can use Python along with the socket and subprocess modules to interact with the network and execute commands remotely. Here’s a basic script that utilizes the psutil library to check the system version remotely:

First, you need to install the psutil library by running:

pip install psutil


import socket
import subprocess
import psutil

def check_remote_windows_version(ip_address, username, password):
try:
# Ping the remote machine to check if it’s reachable
response = subprocess.run([‘ping’, ‘-n’, ‘1’, ip_address], stdout=subprocess.PIPE)
if response.returncode != 0:
print(f”Host {ip_address} is unreachable.”)
return

# Connect to the remote machine using WMI
wmi_command = f”wmic /node:{ip_address} os get version”
process = subprocess.Popen(wmi_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, error = process.communicate()

if process.returncode == 0:
version_number = output.decode(‘utf-8’).strip().split(‘\n’)[1].strip()
if version_number < ‘10.0.19041’:
print(f”Computer at {ip_address} with version {version_number} is outdated and needs an update.”)
else:
print(f”Computer at {ip_address} with version {version_number} is up to date.”)
else:
print(f”Failed to retrieve version information from {ip_address}. Error: {error.decode(‘utf-8’).strip()}”)

except Exception as e:
print(f”An error occurred: {e}”)

if __name__ == “__main__”:
# Replace these values with the actual IP address, username, and password of the target machine
target_ip = ‘192.168.1.2’
target_username = ‘your_username’
target_password = ‘your_password’

check_remote_windows_version(target_ip, target_username, target_password)

 

 

Replace '192.168.1.2', 'your_username', and 'your_password' with the actual IP address, username, and password of the target machine. Keep in mind that this script requires administrative privileges on the target machine for remote execution.

This script sends a ping to the target machine to check if it’s reachable, and then it uses the wmic command to retrieve the Windows version. The version is then compared to a threshold (‘10.0.19041’ in this example) to determine if the computer is outdated. Adjust the threshold based on your requirements.

35 thoughts on “Network Security Script: Check Windows System Updates Remotely”

  1. Wow! This could be one particular of the most beneficial blogs We have ever arrive across on this subject. Basically Fantastic. I am also an expert in this topic therefore I can understand your hard work.

  2. Youre so cool! I dont suppose Ive read anything like this before. So nice to search out someone with some unique ideas on this subject. realy thanks for starting this up. this website is something that is needed on the web, somebody with just a little originality. useful job for bringing one thing new to the internet!

  3. I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

Leave a Reply

Discover more from Sowft | Transforming Ideas into Digital Success

Subscribe now to keep reading and get access to the full archive.

Continue reading