Create firewall rule even if path is not existing

Hello

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.

https://social.technet.microsoft.com/Forums/en-US/a07fbde7-773d-4dea-9863-472a9f8f3050/create-firewall-rule-even-if-path-is-not-existing?forum=winserverpowershell

Thanks