powershell - How can I count running EC2 Instances? -
I use PowerShell to calculate the number of running EC2 example on AWS, looking for a very basic script I am here. I have found many ways, but for some reason when I try them, I do not get the results.
The closest is:
$ instancestate = (get-ec2instance) .instances.state.name $ instancestate
which :
Stopped stopped stopping
(this list is released for approximately 80 instances)
I want to make a reaction that calculates the running people.
I'm not sure about other people, but I clearly have my ec2 filter in the variable I like to specify, and then Get-EC2Instance
. This makes it easy to work with filters if you have to filter in many situations
Here are examples of your work, in which I have 6 running examples:
#FilterPsC: \ & gt; $ FilterRunning = New Object Amazon AC 2 Modell. Filter-property @ {name = "instance-state-name"; Value = "Running"} # Force output of Get-EC2 instance in a collection. PS: \ & gt; $ Running instances = @ (gate-EC 2 instance-filter $ filtering) Count the # running examples (more literally, count the collection iterative) PSC: \ & gt; $ Running instances. Number 6
Comments
Post a Comment