通过 GPO 为本地用户配置文件添加新的防火墙规则

Adding a new firewall rule for a local user profile through GPO

我公司推出了一项新的软件电话服务,该服务已通过 GPO 成功安装到每台机器上。问题是,该软件安装在用户配置文件中,然后要求允许通过 windows defender 防火墙进行访问,而我很难允许需要管理员凭据的访问。 %localappdata% 或 %userprofile% 等变量在 GPO 中不起作用。启动脚本不起作用,因为它将防火墙规则置于管理员配置文件下。登录脚本不起作用,因为它需要管理员权限才能添加新的防火墙规则。

$username = $env:username

New-NetFirewallRule -Displayname "Five9Softphone" -Direction Inbound -Program C:\Users$username\appdata\local\Five9\Five9Softphone-10.0\bin.2.16\five9softphone.exe

这适用于 运行 任何管理员用户但不是我的普通用户。请帮忙!

您可以运行像下面这样的东西:

$profiles = Get-ChildItem -Path 'C:\Users' -Directory
Foreach ($profile in $profiles) {
    $ExePath = Join-Path -Path $profile.Fullname -ChildPath 'appdata\local\Five9\Five9Softphone-10.0\bin.2.16\five9softphone.exe'
    if (!(Get-NetFirewallApplicationFilter -Program $ExePath)) {
        New-NetFirewallRule -Displayname "Five9Softphone" -Direction Inbound -Program $ExePath
    }
}