I'm doing some end to end testing of an application and I need to be able to close then open a port in Windows Firewall using PowerShell commands. I've found a script that adds a firewall rule to open a port, but I also need to be able to close the port.
Is it possible to close the port in similar fashion? I need to close it first, do an operation, then re-open it and perform another operation. Hopefully the commands will work on Windows 7 (for testing locally), and Server 2008 and up.