$StartMenu = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs'
$AppPath = 'C:\Program Files\JetBrains'
$FirewallRules = Get-NetFirewallRule
if(Test-Path -Path $AppPath)
{
$apps = Get-ChildItem -Path $AppPath |Select-Object -ExpandProperty Name
foreach($App in $Apps)
{
$AppName = $App.Split(" ") | Select-Object -First 1
$AppExe = $AppName + '64.exe'
if($AppName -eq 'IntelliJ'){ $AppExe = 'idea64.exe'}
if(Test-Path "$StartMenu\$AppName.lnk"){Remove-Item -Path"$StartMenu\$AppName.lnk"}
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut("$StartMenu\$AppName.lnk")
$shortcut.TargetPath = "$AppPath\$app\bin\$AppExe"
$shortcut.Save()
if(!($FirewallRules | Where-Object {$_.DisplayName -eq $App}))
{
New-NetFirewallRule -DisplayName $App -Direction Inbound -Program $shortcut.TargetPath -RemoteAddress Any -Action Allow -Profile Domain
}
} # End Foreach Region
} # End If Region