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.

22 lines
972 B

  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. $reglas = Get-NetFirewallRule -DisplayName 'EshopDocker'
  17. if ($reglas.Length -gt 0)
  18. {
  19. New-NetFirewallRule -DisplayName EshopDocker -Confirm -Description "Eshop on Containers" -LocalAddress Any -LocalPort Any -Protocol tcp -RemoteAddress Any -RemotePort 5100-5105 -Direction Inbound
  20. New-NetFirewallRule -DisplayName EshopDocker -Confirm -Description "Eshop on Containers" -LocalAddress Any -LocalPort Any -Protocol tcp -RemoteAddress Any -RemotePort 5100-5105 -Direction Outbound
  21. }