Created
January 31, 2022 07:28
-
-
Save martin-juul/08b9bcf90975e076a67ec8bb069ca900 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Creates firewall rules for Teams. | |
.DESCRIPTION | |
(c) Microsoft Corporation 2018. All rights reserved. Script provided as-is without any warranty of any kind. Use it freely at your own risks. | |
Must be run with elevated permissions. Can be run as a GPO Computer Startup script, or as a Scheduled Task with elevated permissions. | |
The script will create a new inbound firewall rule for each user folder found in c:\users. | |
Requires PowerShell 3.0. | |
#> | |
#Requires -Version 3 | |
$users = Get-ChildItem (Join-Path -Path $env:SystemDrive -ChildPath 'Users') -Exclude 'Public', 'ADMINI~*' | |
if ($null -ne $users) { | |
foreach ($user in $users) { | |
$progPath = Join-Path -Path $user.FullName -ChildPath "AppData\Local\Microsoft\Teams\Current\Teams.exe" | |
if (Test-Path $progPath) { | |
if (-not (Get-NetFirewallApplicationFilter -Program $progPath -ErrorAction SilentlyContinue)) { | |
$ruleName = "Teams.exe for user $($user.Name)" | |
"UDP", "TCP" | ForEach-Object { New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Profile Domain -Program $progPath -Action Allow -Protocol $_ } | |
Clear-Variable ruleName | |
} | |
} | |
Clear-Variable progPath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment