Hi all,
Is there any way to monitor whether a VM has been ( or is being ) migrated by DRS via a PowerShell script?
The reason I ask is that I would like to use the Automatic DRS facility within a cluster but have any movements monitored and the VM, its Source and its Destination reported or alerted upon. In this manner I could keep our company Configuration Database up to date and thus keep the pencil pushers off my back.
I appreciate it may be simpler to run a script on a regular basis rather than have it perpetually loop waiting for a migration and thus wasting resources.
I assume that the Recent Task list needs to be searched but if anyone has any brighter ideas I would be very appreciative.
Apologies if this has been asked before and already has an answer only I have Googled this request and have yet to find any pointers.
Thanks
Brucky
Must be something with the clustername and the parameter ($tgtCluster) that is passed to the script.
Is it possible to show how you call the script ? And the name of the cluster you are after ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Okay I've noticed something that may help identify the problem...
When I make the change you suggested... i.e change;
foreach($event in ($ecollection | where{$_.ComputeResource.Name -eq $tgtCluster})){
back to
foreach($event in $ecollection){
then it lists all VM's that have moved in all clusters ... but it (incorrectly) has the names of ESX hosts in the from and to column that are in the cluster I've selected....
So its still listing all events but its somehow replacing the actual source and detination hosts with hosts in the selected cluster....
Does that help ? Does it at least make sense ?
Yes, I think that helped.
There was a problem with the curly braces.
Try this new version of the script
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes that worked ....
Many thanks for your persistence LucD
Mmm ... getting some duplications with the new syntac .... migrations listed several times :smileyconfused:
Could it be that you have multiple connections open to the vCenter.
Can you check with $defaultVIservers and don't forget that the script opens another connection.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Nope just the one connection. Whether running in a cmd shell or in VESI editor same issue, and $defaultVIserver and $defaultVIservers set to single VI server
Using linked mode between 4 VC servers but that doesn't usually cause this kind of thing. Its strange as all entries are repeated either 5 or 6 times... the "to" and "from" ESX hosts are generally the same for each repetition but not always.... very strange...
And is the datetime exactly the same for all the duplicates ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes the date/time is exactly the same...
Ok, last attempt.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Nope ... its again listing all events/vms for all clusters but replacing the actual host names with host names from the cluster selected.
I appreciate the time you've spent on this ... many thanks. I will see if there is a way I can select of lines seperately from the original script (the hosts all have a naming convention I can use in the relevant cluster so I should be able to select just lines where host is like UK-VSPESX1xx)
Hate to dredge up this old thread, but I have this working for me, however it does not return a range of dates. It only returns the specific day I put in the parameter field. For instance, if I put in 5, it only returns five day ago's drs vmotions, not today through 5 days ago, Any ideas?
Normally the TaskFilterSpec.Time takes the timerange defined by beginTime and if there is no endTime, the filter should return all events from start till the latest available events.
You could try specifying the endTime eplicitely, and test if that makes a difference.
Which vSphere version are you running this against ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference