Get Windows Firewall State on Local or Remote Machine Utilizing Netsh.exe

.SYNOPSIS
Displays the Windows Firewall state forĀ Domain, Private, and Public profiles on local or remote computer.

.DESCRIPTION
UseĀ Get-FirewallState to show current Firewall state that is presented on the Windows Firewall with Advanced Security Properties page, with the tabs for Domain, Private, and Public profiles.

.PARAMETER HOSTNAME
Specifies the remote or local computer name.
When using HOSTNAME parameter, Windows PowerShell creates a temporary connection that is used only to run the specified command and is then closed.

.EXAMPLE
Get-FirewallState -HOSTNAME SERVER01

Description
———–
The script will establish remote connection to SERVER01 machine and display the Firewall state for all profiles:

 

Code:

 

Test-AWSEC2 – Detect if a virtual host is running on Amazon EC2

Amazon EC2 Instances have metadata they can access. They get it by accessing a web server on a link-local address 169.254.169.254.
This PowerShell function will attempt to open http connection to the link-local address 169.254.169.254, and if successful will confirm that the host is running on Amazon Elastic Compute Cloud (Amazon EC2).

Function run on AWS EC2 virtual machine.
Function run on AWS EC2 virtual machine.

Code: