Create firewall rule even if path is not existing


I have here a script from Microsoft to create two rules in the Firewall, but after testing, teams application has to be installed, which are not the case for all our corporate devices. Is it possible to change this powershell ,and create the two rules, even if the path doesn’t exist?

Thank you for your help

$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 Any -Program $progPath -Action Allow -Protocol $_ }
Clear-Variable ruleName
Clear-Variable progPath

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to you help making their work twice or more.