Skip to content

Instantly share code, notes, and snippets.

@ProTip
Created November 19, 2014 01:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProTip/c80b1a3a29e488a6dd6d to your computer and use it in GitHub Desktop.
Save ProTip/c80b1a3a29e488a6dd6d to your computer and use it in GitHub Desktop.
cmd = powershell_out("Get-NetFirewallRule -DisplayName 'Block AWS Metadata'")
case cmd.exitstatus
when 1
powershell_out!("New-NetFirewallRule -DisplayName 'Block AWS Metadata' -Action Block -Direction 'outbound' -RemoteAddress '169.254.169.254' -RemotePort '80' -Protocol 'tcp' | Get-NetFirewallSecurityFilter | Set-NetFirewallSecurityFilter -LocalUser 'O:LSD:(D;;CC;;;SY)(D;;CC;;;LA)'")
when 0
powershell_out!("Set-NetFirewallRule -DisplayName 'Block AWS Metadata' -Action Block -Direction 'outbound' -RemoteAddress '169.254.169.254' -RemotePort '80' -Protocol 'tcp' ")
powershell_out!("Get-NetFirewallRule -DisplayName 'Block AWS Metadata' | Get-NetFirewallSecurityFilter | Set-NetFirewallSecurityFilter -LocalUser 'O:LSD:(D;;CC;;;SY)(D;;CC;;;LA)' ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment