You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1.1 KiB

  1. param([switch]$Elevated)
  2. function Check-Admin {
  3. $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
  4. $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
  5. }
  6. if ((Check-Admin) -eq $false) {
  7. if ($elevated)
  8. {
  9. # could not elevate, quit
  10. }
  11. else {
  12. Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
  13. }
  14. exit
  15. }
  16. try {
  17. Get-NetFirewallRule -DisplayName EshopDocker -ErrorAction Stop
  18. Write-Host "Rule found"
  19. }
  20. catch [Exception] {
  21. New-NetFirewallRule -DisplayName eShopOnContainers-Inbound -Confirm -Description "eShopOnContainers Inbound Rule for port range 5100-5150" -LocalAddress Any -LocalPort 5100-5150 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Inbound
  22. New-NetFirewallRule -DisplayName eShopOnContainers-Outbound -Confirm -Description "eShopOnContainers Outbound Rule for port range 5100-5150" -LocalAddress Any -LocalPort 5100-5150 -Protocol tcp -RemoteAddress Any -RemotePort Any -Direction Outbound
  23. }