VM Power Off Date

I created annotations for my virtual computers called LastPowerOn and LastPowerOff, I had planned to transfer the CreationDate from the entrance to the event log for 'VmPoweredOnEvent' and 'VmPoweredOffEvent' respectively.  Unfortunately, it seems that not all the events of power in newspapers are determined by the name of the event.  In vCenter, I view turn the events that do not appear as such.

After trying my hand in this area and short coming, I borrowed a screenplay written by RvdNieuwendijk, which was designed to analyze the event logs VM for exactly this info.  This script also resulted in empty info for multiple servers.  So looking at the event log, this event seems not to appear the same as a manifestation of normal power:

On DRS on the virtual machine
Esx1.Jeff.com
Info
28/10/2011-13:57:25
Power on virtual machine
server100

This is the code I use to test:

Get-VIEvent -Entity $vm -MaxSamples 500 | Sort-Object -Property CreatedTime -Descending | Where-Object { $_.Gettype().Name -eq "VmPoweredOnEvent" } | Select-Object -First 1

I fell the MaxSamples up to 500 to see if that was the problem.

I can find the exact event, so I'm looking for:

Template             : False
Key                  : 11657
ChainId              : 11651
CreatedTime          : 10/28/2011 1:57:25 PM
UserName             : 
Datacenter           : VMware.Vim.DatacenterEventArgument
ComputeResource      : VMware.Vim.ComputeResourceEventArgument
Host                 : VMware.Vim.HostEventArgument
Vm                   : VMware.Vim.VmEventArgument
Ds                   : 
Net                  : 
Dvs                  : 
FullFormattedMessage : DRS powered On server100 on esx1.jeff.com in
                       DataCenter1
ChangeTag            : 
DynamicType          : 
DynamicProperty      :

Any suggestions on where to go from here would be very useful.

I thought to go to the data store and pulling the last modified date date the vmdk to establish a 'rough' power.

Thank you

Jeff

Hi jeff,

Thanks for your question. You found a serious flaw in my script from the thread to get a SSN last turning off date based on events of the virtual machine.

And thanks to your suggestion, it was not difficult for me to change the line:

Where-Object {$_.} GetType(). Name - eq "VmPoweredOnEvent"} | `

in:

Where-Object {$_.} GetType(). Name - eq "VmPoweredOnEvent" - or $_. GetType(). Name - eq "DrsVmPoweredOnEvent"} | `

to solve your problem.

Looking again my previous script, I found two other holes myself. You can probably say: "age comes with insight".

The most serious is that the Get-VIEvent cmdlet returns only by the 100 default events. Maybe it's too small for some VM. So I added the MaxSamples parameter with value of 10000. Even if it is necessary to make the script executed well, it will make the script much slower.

The other minor problem is that the previous script did the Sort-Object cmdlet in the pipeline before the Where-Object cmdlet. It is best to do the opposite. It is much faster because the Sort-Object cmdlet must sort the records less.

Here's the new script will all changes:

function Get-VMLastPoweredOffDate {
  param([Parameter(Mandatory=$true,ValueFromPipeline=$true)]
        [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm)
  process {
    $Report = "" | Select-Object -Property Name,LastPoweredOffDate,UserName
    $Report.Name = $vm.Name
    $Event = Get-VIEvent -Entity $vm -MaxSamples 10000 | `
      Where-Object { $_.GetType().Name -eq "VmPoweredOffEvent" } | `
      Sort-Object -Property CreatedTime -Descending | `
      Select-Object -First 1
    $Report.LastPoweredOffDate = $Event.CreatedTime
    $Report.UserName = $Event.UserName
    $Report
  }
}

function Get-VMLastPoweredOnDate {
  param([Parameter(Mandatory=$true,ValueFromPipeline=$true)]
        [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl] $vm)

  process {
    $Report = "" | Select-Object -Property Name,LastPoweredOnDate,UserName
    $Report.Name = $vm.Name
    $Event = Get-VIEvent -Entity $vm -MaxSamples 10000 | `
      Where-Object { $_.GetType().Name -eq "VmPoweredOnEvent" -or $_.GetType().Name -eq "DrsVmPoweredOnEvent"} | `
      Sort-Object -Property CreatedTime -Descending |`
      Select-Object -First 1
    $Report.LastPoweredOnDate = $Event.CreatedTime
    $Report.UserName = $Event.UserName
    $Report
  }
}

New-VIProperty -Name LastPoweredOffDate -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOffDate -vm $Args[0]).LastPoweredOffDate} -Force
New-VIProperty -Name LastPoweredOffUserName -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOffDate -vm $Args[0]).UserName} -Force
New-VIProperty -Name LastPoweredOnDate -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOnDate -vm $Args[0]).LastPoweredOnDate} -Force
New-VIProperty -Name LastPoweredOnUserName -ObjectType VirtualMachine -Value {(Get-VMLastPoweredOnDate -vm $Args[0]).UserName} -Force

Get-VM | Select-Object -property Name,LastPoweredOnDate,LastPoweredOnUserName,LastPoweredOffDate,LastPoweredOffUserName

Best regards, Robert

Post edited by: RvdNieuwendijk added the - Force parameter to the commands of the new VIProperty.

Tags: VMware

Similar Questions

  • migration of data store has failed - now there are two vm - one power off?

    I was migrating a vm fw at different stores of data when a failure has occurred. They may have been cancelled or it may have been the fact that our vcenter server has restarted. I don't know if this would have caused this problem.

    In any case, now, two of the VM series two - power and the other copies are turned off. One that is off is the data store b and the virtual machine is the one data store. The strange thing is, shows of b (power off vm) data store which is where the files are located while the virtual machine is on a. When I browse a datastore I cannot find all files... It just hangs. I googled but am stuck.

    See the screenshots for more details. Thanks in advance!

    Edit: finally to load two data warehouses. They both show identical files: vmdk, vmfx, vmsd etc. for the two virtual machines on two data stores. It's weird!

    Edit 2: or vm, on or off, power to the high/off or migrate or remove from the inventory. Both are 'ping' and one that is good though.

    I figured this out. I have ssh was the host of the virtual machine is on (the two virtual machines were on the same hosts). Down to power, I ran the following command "esxcli vm kill process - type = soft - world id = xxxxx."

    That he got the vm to stop. The virtual machine of the same name already powered off then showed as "orphans". I removed the orphan vm of the inventory, the other vm started automatically acknowledgement of receipt, then I deleted the orphan vm of the 2nd data store.

  • message "Turn power off, t.

    My printer Officejet 4620 randomly displays the message 'Turn power off, t' on the screen and do not respond to orders, or the button walk stop. Tried to access the Internet through the web server, but do not respond. The only way to reset is to disconnect the power cord...

    Hi @N3oN79Italy

    I'm sorry to hear that you are having problems with your Officejet 4620.

    You have the printer connected directly to a wall outlet or is this a surge protector or power bar? Even if you have used a surge protector/power bar this whole time and you feel that this is not the case, please connect to a wall outlet so that we can eliminate the source of energy as the primary cause.   Questions when it is connected to an uninterruptible power supply/Strip/surge protector power

    In this document, you will see, QUESTION: questions or problems may arise when a HP LaserJet printer is connected to a UPS (UPS), a power strip or a surge protector

    ↑ This is not limited to the Laserjet printers.

    In addition, click on the link below to make sure that the printer has the latest firmware update. This update of the firmware can improve the performance of the printer and fix various defects.

    HP Officejet Firmware

    If the problem persists, call HP. If you are in the Canada, U.S. dial 800-474-6836 or you can Contact HP worldwide.

    HP printers usually have a warranty of 1 year from the date of purchase, you can check the warranty using the following if you wish; guarantee cheque.

    I hope this helps.

  • After that turn the power off for a few days and then back on... all my desktop ICONS was reorganized.

    After that turn the power off for a few days and then back on... all my desktop ICONS changed. I placed the worms where I want that they and computer restarted and they get rearranged again. Help, please.

    Hello Kenneth Pincus,

    You can create a new profile on the computer and if the desktop icons stay on their position. If this is not the case, the other profile is corrupt. To create a new user profile, you can see the article mentioned below for the procedure.

    How to create and configure user accounts in Windows XP

    http://support.Microsoft.com/kb/279783

     

    How to copy data from a corrupted to a new profile in Windows XP user profile

    http://support.Microsoft.com/kb/811151

    Let us know the results.

  • Sudden power off of the show on X 220 Tablet with accumulator

    We discovered this problem in early August with our new X 220 tablets.  We have a 1 to 1 tablet pc program.  About 75% of our first grade class has experienced this problem.  The tablets are running on battery power with its long battery life.  Units spontaneously just will be turn off.  Not a clean shutdown but just a power off.  The batteries are in different States, when this happens, most of the time that both batteries are almost full.  I've seen this dozens of times with the students in my classes.  We discovered that it also affects another high school on our consortium.  Bulk buy our tablets with several other secondary schools.  Another school that has this problem has the same model and the manufacturer even date 11/06/2012.  It is estimated that 200 to 300 units are allocated between the two schools.  Lenovo product engineers work on the search for the source of the problem, but we have many frustrated students and parents.  Just curious if anyone else has experienced this problem with X 220 tablets and slices that were made around the first part of June?


  • Problem with my Treo Windows Mobile 6.1 800w (Sprint) always connect to internet via Power Vision data services?

    I don't know if it's a good 'problem' or not (I don't see anything during my brief search), but Im wondering if anyone else has the same problems.

    I really like this phone compared to my previous 755 p, but I have two gripes in this regard.  First of all, there is no light that flashes when an alert or notification has taken place, or a call came, etc., as had the 755 p.  Why would this feature removed?  If the screen of the phone is off and vibrate (like how my phone is at work), you'd never know unless you have checked the phone or had put on alert constantly rehearsing and vibrate my office all day.  I can live with, I guess, but an update or application that could resolve this would be great.

    The real problem I have is with the phone always tries to connect to Sprint Power Vision Data services via #777 to synchronize my email accounts.  I have all the e-mail settings (Outlook and Gmail Pop) to manually check for new messages, and the UNCHECKED check box to enable the internet connection.  But every few minutes, or if a message appears asking to connect to the internet even if everything is set to manual.  It is so ANNOYING so now I just put it to stay connected.  The real problem is that it seems to be to kill the battery even more fast because its connected throughout the day.  Im trying to minimize consumption to save the battery life (turn down the backlight, disabled WiFi, screen turn off immediately when done using the TI, etc.), but I'm close to the point to get rid of the phone if I can't understand it.  Its a new phone and battery (Christmas gift) and I think that the battery should last more than a full day even with the light for no use.  I don't use the phone that much but it honestly be dead from 22:00 with only plain text messages and phone will use during the day.  I have probably of less than 200 minutes per month.

    I contacted the Palm support and worked with someone for a while, and it doesn't seem to be sure if it was supposed to be like that or if there was a problem.  In the end we left it as it was and he said I need to contact Sprint to see if they have something in their automatic configuration that makes the phone connect ALL THE TIME.  I still have to communicate with them, and I'd like to hear what others have to say.

    Don't make me get an iPhone lol.

    Thank you

    Ryan

    Well, I guess I figured out how to stop it from asking me to connect to the internet EVDO service every few minutes.

    It seems he was trying to do because of my two Pop email accounts I have set up.   On the enamel of the Options screen, it lists the e-mail accounts and there is an asterisk next to one of them.  If I leave the asterisk next to "Outlook E-mail" then it seems not repeatedly, try to connect to internet EVDO.  If I leave the asterisk next to one of Pop email accounts, he seems to want to connect to EVDO repeatedly.  I guess that the asterisk indicates the default or the main e-mail account of something, then he tried to update via internet services.  I guess that Outlook is configured to only update when a synchronization is performed, or something.  so if I browse the web with IE, I just manually disconnect after the browsing session and it is more requested to connect to EVDO when the asterisk is next to "Outlook email" in the list of accounts on the Options screen.

    Note, with some other applications and tweaks installed that I found on the forums, my battery life is now acceptable even with normal use.  still has 30% left before going to bed each night.

    Message is about: Treo 800w (Sprint)

  • How to know from a virtual machine is power off?

    Hi all

    I want to know if it is possible to find it on the database or somewhere else a parameter allowing to know since when a Virtual Machine is power off.

    In fact, I want to analyze what Virtual Machine are not used and since when...

    My level = vSphere4.1

    TKS

    It's strange, that I always find VmPoweredOffEvent entries, even when the user has launched a stop from in the guest OS.

    You can easily test.

    • Make a stop of in a guest
    • When the virtual machine is turned off, do
    Get-VIEvent -Start (Get-Date).AddMinutes(-30) -Entity MyVM | Select CreatedTime,@{N="Event";E={$_.GetType().Name}}
    

    You should see that you triggered

  • Bug: iOS 10, Siri invades even lock screen with power off

    iOS 10, Siri invades even lock screen with power off

    Since the upgrade to iOS 10 (iPhone 5 s) siri appears when I forgetting to unlock my phone because I'm not used to this way to unlock yet. But siri on lock screen is disabled in the settings. I can close siri all together, but I don't consider it as an option.

    Is this a bug in the iOS 10 or did I miss something?

    Hello nick_ve,

    Thank you for using communities of Apple Support.

    I see that since you have upgraded to iOS 10, Siri starts each time you try to unlock your iPhone and Siri on the lock screen is disabled in the settings. I completely understand, because when I upgraded, it took me a few tries to get adjusted to unlock with the Home key. I'm more than happy to help you with this.

    Press the Home button on your iPhone 5s once unlocks the screen, and freezes for more than one second will activate Siri. It is good to keep this in mind when you unlock your iPhone.

    There is also an alternative solution I would like to share with you. You can disable this option in settings > general > accessibility > Home button. Turn the finger remains open. You can unlock the iPhone with Touch ID without having to press the Home button.

    Have a wonderful day!

  • AppleScript to disable auto power off

    Hey guys,.

    I was wondering if there was a way to disable the automatic stop for a mac using Applescript.

    Thank you.

    Mac OS: El Capitan

    MacBook Air early 2015

    What did you use to enable auto power off?

    Do you mean the stop programmed in system energy-saving Preferences?

  • unmatched iwatch of iphone and incorrect password (power off) gray of iwatch

    My iwatch is locked and it is showing the error "wrong access code open the Apple Watch app on your iphone, go to access code, then tap reactivate entry password to try again. I tried the hard reset, but it did not work. I can't reset the iPhone because it is non-matched and when I tried to reset to iwatch again then power off and power reserve options are grayed out.

    Can someone help me please?

    Hello

    Follow these steps to clear your locked Watch:

    • Connect your watch to its charging cable - with power connected.
    • Hold down the side button until you see the cursor off the power.
    • Press firmly (IE more firmly than usual) on Power Off and then press erase content and settings.

    Then re-pair shows your watch by using the app on your iPhone, choose to restore from backup when the possibility.

    More information:

    Set up your Apple Watch - Apple Support

    If you have forgotten the password for your Apple Watch - Apple Support

  • HP Color LaserJet M277dw MFP: Disable auto power off after inactivity for HP Color LaserJet M277dw MFP

    What is the purpose of mobile printing solutions if you cannot activate your home printer?
    My printer stop automatically after 8 hours of inactivity and therefore makes it impossible for me to use mobile printing. The printer is connected via WLAN (without active ports to stop the closing).
    In the configuration, there are only options to stop after 2, 4 or 8 hours. No option on disabling of automatic shutdown.
    Pls do that for the people who work on the firmware updates, they must include an option to disable auto power off, many people are already complaining that and nothing has changed so far.
    Its just illogical. You make big announcements for HP eprint and other stuff, but your printers are not able to do so even if you could theoretically make eprint if your standing next to your printer all day.
    I just got this printer pluged and installed and already tired of this BS!
    I know that there is no solution, so just send it to the people who can change it.

    for all of you who read this post, I was in contact with the technical team of HP and they said that they don't give you the ability to disable auto power off on purpose, it is HPs energy-economy-policy to do and there are no plans to change this in the future
    in my case, I only WLAN's, yet is not automatically stop (although it should be), I guess I'm lucky that my router it ping every now and then and is therefore not stop
    If you can't fix it yourself with active ports and may not have at all, it will probably not option left than the back of the printer

  • Is it possible to stop auto power off while downloading?

    Is it possible to stop auto power off while downloading?

    Can you please be more specific with your problem?
    What model of laptop do you have?

    What happens exactly and when?

  • Satellite A660 - player optical power: OFF

    I have an A660 and I'm doing a system repair disc, but the message "Windows has not found that a CD/DVD burner rises. I also noticed that the icon on the right side of the taskbar indicates that the "Optical Drive Power: OFF '.

    I am running Windows 7. I think it may be a setting outside the energy saving eco utility.
    Someone please offer little help on this it would be much appreciated.

    Thank you.

    Hello

    By pressing FN + TAB turns the power of the STRANGE power or eject disc tray... Try this...
    If this does not work, check the Toshiba ODD utility

    All programs-> Toshiba-> CD & Applications DVD

    Welcome them

  • Pavilion 15: Power off

    I have to use the shift with off switch key (on windows 8) to power the laptop off, if I use only only its turning off the display only, but is always cut power off button.

    Hello

    Try disabling the hybrid Windows 8 start - you can do the following.

    Right-click the battery icon, and select Power Options.  In the next window, click on "Choose what the power button" in the left pane.

    In the next window, click on "Change settings that are currently unavailable" (close), then Remove the check mark from the box against 'Turn on a quick start (recommended) '.  Click on the button Save the settings, and then close all open windows and check if the laptop will now be shut down properly.

    If this has fixed the problem, it may be useful by turning the quick start back on - sometimes simply remove and re-create the file will solve the problem.

    Kind regards

    DP - K

  • Please explain power off icons

    On a 10 B8000 Yoga, when I choose to turn it off, I get a window which displays three lines:

    > Power off

    > Airplane mode

    and the third line has 4 icons:

    > a speaker with an X.

    > a tablet with two wavy lines,.

    > a speaker with two concentric arcs.

    > and two trees.

    I think that I understand the first 3, but what the heck are the two trees for?

    I tried to select and cannot tell any difference in the operation of my tablet.

    (Btw, I called Lenovo support with this question THREE TIMES and after speaking to FOUR rehearsals and lots and lots of waiting time, nobody knows the answer, most don't know what screen I hate...)

    exilio wrote:

    On a 10 B8000 Yoga, when I choose to turn it off, I get a window which displays three lines:

    > Power off

    > Airplane mode

    and the third line has 4 icons:

    > a speaker with an X.

    > a tablet with two wavy lines,.

    > a speaker with two concentric arcs.

    > and two trees.

    I think that I understand the first 3, but what the heck are the two trees for?

    I tried to select and cannot tell any difference in the operation of my tablet.

    The speaker with the mutes the audio with vibrate mode off X.

    The tablet with two wavy lines on mute, but turn on vibrate mode.

    The pregnant with two arcs UN-mutes the audio and turns off vibrate mode.

    I don't know what the "two trees" icon is.

Maybe you are looking for