I am writing a script to do a silent install of a program on a windows machine using powershell. However I am hitting an issue where the program does not properly setup the machine's windows firewall settings. Is their a way for a powershell script that is being remotely executed to add a firewall port exception?

有帮助吗?

解决方案

You need to have remoting enabled on remote computer ( Enable-PSRemoting ). Enter in the remote session ( Enter-PSSession -ComputerName remotecomputername ) Then you can use the native commandline netsh to Enable/Disable Windows firewall using:

netsh firewall set opmode
                   [ mode = ] ENABLE|DISABLE
                   [ [ exceptions = ] ENABLE|DISABLE
                   [ profile = ] CURRENT|DOMAIN|STANDARD|ALL
                   [ interface = ] name ]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top