PowerShell: Check firewall status on all servers in a domain

To check the status of the firewall on all servers in the domain using PowerShell, following script can be used. This script will remotely query each server in the domain to check the status of the Windows Firewall service.

Make sure to run the script with appropriate administrative privileges.

Copy code

Replace -SearchBase with the name of your actual domain and the organizational unit (OU) you want to search. The script uses the Get-ADComputer cmdlet to fetch all server objects from the ”Servers” organizational unit (OU) in the domain. It then loops through each server, queries the status of the ”MpsSvc” (Windows Firewall) service using the Get-Service cmdlet, and prints the result on the console.

Please note that for this script to work, you need to have the necessary permissions to access the servers remotely and query the firewall service status. Additionally, make sure that you have Active Directory PowerShell module installed to run the Get-ADComputer cmdlet.