VMWorld 2014 - Are you attending?

If not, I highly recommend you register.  Not only is it a fun time, it's probably one of the best 'training' experiences you can get.  In combination w/ the hands-on labs, you'll have access to some of the industries best known experts for immediate answers to your pressing questions.  VMware is also offering 50% off their VCP/VCAP examinations if taken while onsite.

Registration Link:

Letter to convince your Boss:

VMUG Advantage Discount:
By joining the VMUG Advantage program, you can take off $100 of registration among other benefits.

For those who are attending:
VMUnderground - http://blog.vmunderground.com/
VMWorld 2014 5k Fun Run - http://download3.vmware.com/vmworld/2014/downloads/fun-run-info.pdf

Recommended Session:
INF1601 - Taking Reporting and Command Line Automation to the Next Level with PowerCLI
Always a hit!

Swingbench, OEWizard.bat, and Java fun...

I'll keep this short.  Using Java 7 (1.7) seems to cause this issue:
Error occurred during initialization of VM
Could not reserve enough space for object heap

Upgrading/Installing Java 1.8 "JDK" seems to fix the above issue.  Adding -Xmx<#>m would not fix the issue either.

Anyway, figured I'd post this since I really couldn't find an answer to this bizarre issue.

Get-VIEventsFaster PowerCLI function...

[Update: Come to find out LucD wrote a Get-VIEventPlus function that I did not find before making mine.  He adds some other switches that might be useful, same idea though.  Just tells me I really should keep up on his blog more often.]

I wrote this function so I could replace the Get-VIEvent cmdlet in my scripts.  The great part is that the output ends up being roughly the same as the cmdlet so just changing my calls to this custom function speeds everything up like 100-fold.  That might be an exaggeration, but yeah, it's WAY faster.

It's written so that most get-vievent common switches are included.  Syntax is 'slightly' different, but usable so you don't have to modify any get-vievent calls too heavily.  I added a 'type' switch which will help shave off even MORE time.  Anyway, feel free to give it a try or let me know if you have any feedback.

Finally, It's written like a cmdlet so you can import it as a module or dot source it.  I've included some examples as well.

The 'entity' switch works 'ok' if you give it a variable captured object like:
$myVM = Get-VM myVMName
Get-VIEventsFaster -Entity $myVM

I want it to work like this:
$myVM | Get-VIEventsFaster -Entity $_
but I can't get it work like this, but $_ or inference doesn't work like how I think it should.  Just my lack of knowledge here really.

Function Get-VIEventsFaster
  Uses the PowerCLI Get-View cmdlet to query for events.
  This is meant to replace the Get-VIEvent cmdlet in scripts for faster results w/o dramatic changes to code.
  .PARAMETER server
  Connects to vCenter or ESXi server specified.
  .PARAMETER start
  The beginning of the time range. If this property is not set, then events are collected from the earliest time in the database. 
  .PARAMETER finish
  The end of the time range. If this property is not specified, then events are collected up to the latest time in the database. 
  An array of event types can be specified as a filter.  See examples to see how to get a valid list of event types.
  .PARAMETER entity
  Looking for a vSphere object, VM, host, or otherwise. 
  $Date = Get-Date ; $Events = Get-VIEventsFaster -Start ($Date.AddMonths(-1)) -Finish $Date
  Gets all events from 'exactly' 1 month ago to today and captures them in the $Events variable.  
  If Get-Date returned Friday, June 13, 2014 11:00:46 AM, one month ago would be Tuesday, May 13, 2014 11:00:46 AM.
  $Date = Get-Date ; $Events = Get-VIEventsFaster -Start ($Date.AddMonths(-1)) -Finish $Date -Type "VmCreatedEvent","VmClonedEvent","VmDeployedEvent"
  Gets specified event types from 'exactly' 1 month ago to today and captures them in the $Events variable.  
  If Get-Date returned Friday, June 13, 2014 11:00:46 AM, one month ago would be Tuesday, May 13, 2014 11:00:46 AM.
  $Events | % {($_.gettype()).name} | select -Unique
  You can use this one liner to determine valid event 'types'
param (
    [Parameter(Mandatory=$False,HelpMessage="ESXi or vCenter to query events from.")]

    [Parameter(Mandatory=$False,HelpMessage="Start Date to begin gathering events")]

    [Parameter(Mandatory=$False,HelpMessage="End Date to finish gathering events")]

    [Parameter(Mandatory=$False,HelpMessage="Filter down to types of events")]
    [Parameter(Mandatory=$False,ValueFromPipeline=$True,HelpMessage="Looks for events associated w/ specified entity or entities")]
    $AllEvents = @()
    $em = get-view -Server $Server EventManager
    $EventFilterSpec= New-Object VMware.Vim.EventFilterSpec
    If (!$Server)
    If (!$global:DefaultVIServers){Write-Host "You don't appear to be connected to a vCenter or ESXi server." -ForegroundColor:Red; Break}
    $Server = $global:DefaultVIServers[0]
    If ($EventType)
        $EventFilterSpec.EventTypeID = $EventType
    If ($Start -or $Finish)
        $EventFilterSpec.Time = New-Object Vmware.Vim.EventFilterSpecByTime
    If ($Start)
        $EventFilterSpec.Time.BeginTime = $Start
    If ($Finish)
        $EventFilterSpec.Time.EndTime = $Finish
    If ($Entity)
        $EventFilterSpec.Entity = New-Object VMware.Vim.EventFilterSpecByEntity
        $EventFilterSpec.Entity.Recursion = "self"
        $EventFilterSpec.Entity.Entity = $Entity.ExtensionData.MoRef
    $evCollector = Get-View -Server $Server $em.CreateCollectorForEvents($EventFilterSpec))
    $PageEvents = $evCollector.ReadNextEvents(100)
    While ($PageEvents)
        $AllEvents += $PageEvents
        $PageEvents = $evCollector.ReadNextEvents(100)
End {$evCollector.DestroyCollector()}
Additional Info:
Time Difference (my function is 900% faster):
Measure-command {Get-VIEventsFaster -Start ($date.AddMonths(-1)) -Finish ($date)}
Hours             : 0
Minutes           : 12
Seconds           : 57
Milliseconds      : 622
Ticks             : 7776226103
TotalDays         : 0.00900026169328704
TotalHours        : 0.216006280638889
TotalMinutes      : 12.9603768383333

Measure-command {Get-VIEvent -Start ($date.AddMonths(-1)) -Finish ($date)}
Hours             : 1
Minutes           : 48
Seconds           : 59
Milliseconds      : 880
Ticks             : 65398800684
TotalDays         : 0.0756930563472222
TotalHours        : 1.81663335233333
TotalMinutes      : 108.99800114

You can use this one liner to determine what 'names' constitute a valid event 'type':
$Events | % {($_.gettype()).name} | select -Unique