Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get-VM state question

$
0
0

Hey all, quick question...Im sure its a simple solution that i am overlooking, any how below is something I started. The main goal of this script is just to monitor a specific Hyper-V VM and when its state is anything other than 'RUNNING' then display a message on the screen (for debug/testing purposes only for now) but eventually i will change it to send an email to the administrators group.

$state= Get-VM –name DNS.SERVER | where { $_.State –ne ' '} 
if($state -eq "Running"){ msg /server:V1 */v hi}
else {msg /server:V1 */v bye}

What am i doing wrong, it seems whether or not the state of the vm is running or off the script will always display "BYE"


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>