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"