We had an issue yesterday where we needed to quickly get the status of all of our Windows VM's. We needed and still need a way to quickly identify if the OS is up and running, not just whether the guest is in a powered on state.
Most of our guests have "tools old" because we are the process of upgrading to U4. Our environment is 100% Windows.
Can I report on Guest OS on-line easily? If so, then at the end of the report can it be redirected into an .xls or .csv format?
vCenter 2.5.0U5
ESX 3.5.0U3/U4
Thanks in advance
If I understand the thread correctly you want to be able to find guests that are powered on but where the OS is not running since it's not installed ?
The following simple script will create a CSV file which reports on different types of states of all your guests.
$report = @() Get-View -ViewType VirtualMachine | %{ $row = "" | Select VMname, PowerState, ToolsStatus, GuestHeartbeatStatus $row.VMname = $_.Name $row.PowerState = $_.Summary.Runtime.PowerState $row.ToolsStatus = $_.Guest.ToolsStatus $row.GuestHeartbeatStatus = $_.GuestHeartbeatStatus $report += $row } $report | Export-Csv "C:\VM-States.csv"
If you look in the CSV and select the guests which have a powerstate of "poweredon" and a GuestHeartbeatStatus of "red" you will have found the guests you were looking for.
If you want a script that reports only those guests, an if statements in the previous script will do the trick.
$report = @() Get-View -ViewType VirtualMachine | %{ $row = "" | Select VMname, PowerState, ToolsStatus, GuestHeartbeatStatus $row.VMname = $_.Name $row.PowerState = $_.Summary.Runtime.PowerState $row.ToolsStatus = $_.Guest.ToolsStatus $row.GuestHeartbeatStatus = $_.GuestHeartbeatStatus if($row.PowerState -eq "poweredon" -and $row.GuestHeartbeatStatus -eq "red"){ $report += $row } } $report | Export-Csv "C:\VM-States.csv"
I hope this is what you're looking for ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Neil! I do in fact have that website bookmarked, but haven't found exactly what I'm looking for there.
It may be as simple as the code below, but I wanted to roll it all up into something easier if there is a way.
Get-VM | where {$_.PowerState -eq "PoweredOn"} | Get-VMGuest | select VmName, State
The above code is good, however it doesn't give me exactly what i'm looking for. I would also like to report on powered off guests, which the code above doesn't.
...and does "running" mean the OS is on-line? I would assume so, since I believe the running means the VMware Tools service is started. I know i'm asking a lot, but maybe.....
Could you check to see if the tools were running as the OS has to be up for the tools to report a running state?
EDIT: Or even the vm heartbeat?
Thanks,
Neil
the above code does that, if I redirect the output to a .csv it gives me a status of "running" or "not running", which is good. I just need to add more to the script so that it will also report on powered off VM's, or VM's that are in a powered on state, but the OS has not come up. We sometimes have VM's that go down hard and when they reboot they reboot to "no OS found". So the VM is powered on, but the OS is not loaded.
So If I can quickly identify the powered off VM's or the VM's that are powered on but No OS has loaded, that would be ideal!!
hmm... apart from scripting an array with the power state and the tools state and running a comparision I'm out on this one I'm afraid...
Thanks,
Neil
If I understand the thread correctly you want to be able to find guests that are powered on but where the OS is not running since it's not installed ?
The following simple script will create a CSV file which reports on different types of states of all your guests.
$report = @() Get-View -ViewType VirtualMachine | %{ $row = "" | Select VMname, PowerState, ToolsStatus, GuestHeartbeatStatus $row.VMname = $_.Name $row.PowerState = $_.Summary.Runtime.PowerState $row.ToolsStatus = $_.Guest.ToolsStatus $row.GuestHeartbeatStatus = $_.GuestHeartbeatStatus $report += $row } $report | Export-Csv "C:\VM-States.csv"
If you look in the CSV and select the guests which have a powerstate of "poweredon" and a GuestHeartbeatStatus of "red" you will have found the guests you were looking for.
If you want a script that reports only those guests, an if statements in the previous script will do the trick.
$report = @() Get-View -ViewType VirtualMachine | %{ $row = "" | Select VMname, PowerState, ToolsStatus, GuestHeartbeatStatus $row.VMname = $_.Name $row.PowerState = $_.Summary.Runtime.PowerState $row.ToolsStatus = $_.Guest.ToolsStatus $row.GuestHeartbeatStatus = $_.GuestHeartbeatStatus if($row.PowerState -eq "poweredon" -and $row.GuestHeartbeatStatus -eq "red"){ $report += $row } } $report | Export-Csv "C:\VM-States.csv"
I hope this is what you're looking for ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I think something like what you just put together will work great.
If I understand the thread correctly you want to be able to find guests that are powered on but where the OS is not running since it's not installed ?
sort of... What happens sometimes when these VM's go down hard, upon reboot they come up with No OS found. A simple reset of the VM gets everything working again.
I appreciate your help!