I'm looking for a very basic script to count the number of running EC2 instances at AWS using PowerShell. I have found several methods but for some reason when I try them, I do not get the results I expect.
The closest I have is this:
$instancestate = (get-ec2instance).instances.state.name
$instancestate
which returns:
stopped
running
stopped
stopped
running
(the list goes on for about 80 instances)
I wish to have a response that counts those which are running.