Export of Get-VIEvent event
Hello
I found the get-vievent command output looks like this
model: false
key: 8240
chainId: 8240
Createduserid: 2009-03-23 14:38:03
user name:
Data Center: VimApi.DatacenterEventArgument
computeResource: VimApi.ComputeResourceEventArgument
Host: VimApi.HostEventArgument
VM: VimApi.VmEventArgument
fullFormattedMessage: Machine virtual viedfs1-clone is connected
dynamicType:
dynamicProperty:
It is possible to get there real name of the host instead of the value VimApi.HostEventArgument?
What I'm trying to do is to get the list of errors and warnings with time stamp, name the source (host or guest) and completely formatted message. Perfect example is event VC GUI export
Error 2009-01-30 12:43:20 cannot communicate with a primary agent of HA cluster Cluster1 in Test environment
error 30/01/2009 12:43:20 abcd.fqdn.com host in Test environment does not
It is possible to reproduce the logfile that way by VI toolkit?
Thnx a lot
The following should do what you want.
Note that I have export text to a CSV file, which makes it easier to see the different areas
$report = @() get-vievent -Types Error,Warning -Start (Get-Date).addminutes(-15) | %{ $row = "" | Select Time, Text, Host $row.Time = $_.CreatedTime.ToString() $row.Text = $_.fullFormattedMessage if($_.host -ne $null){ $row.Host = $_.host.name } else{ $row.Host = "" } $report += $row } $report | Export-Csv "C:\report.csv" -noTypeInformation
Post edited by: LucD
Just noticed I put 1500 instead of 15 as an argument to the addminutes method.
Tags: VMware
Similar Questions
-
Get-VIEvent - how to export the event type? error, warning, or info
Hello
I know that the Get-VIEvent command allows you to specify the type of events to get back... that is to say [-Types < EventCategory [>]
but, I want to extract all the events and export them to a CSV file. I want one of the columns to be "EventCategory", which will be ERROR, WARNING, or INFO, but I can't seem to find it. $_. GetType(). Name gets me the type of event, but not the category. I know that I can have my script executed 3 times (each time specifying the - parameter Types) but I want to run only once. Any ideas?
Thank you!
Jeff
Hello, horningj-
I worked on a few elements that should attract the event category. The first selects a few properties, including a calculated property that gets the event category:
## works well if no events of type 'EventEx'## get the .Net View object of the EventManager (used for getting the event Category) $viewEventMgr = Get-View EventManager ## get some VIEvents, select a few properties, including a calculated property for EventCategory Get-VIEvent | Select FullFormattedMessage, CreatedTime, @{n="EventCategory"; e={$strThisEventType = $_.GetType().Name; ($viewEventMgr.Description.EventInfo | ?{$_.Key -eq $strThisEventType}).Category}}
It becomes VIEvents (the last 100, because I did not specify the parameter - MaxSamples) and returns the properties of data. The calculated "EventCategory" property uses the type of the VIEvent object to search for in the collection of items EventDescriptionEventDetail in ownership eventInfo found in .net object View for the EventManager. He then grabs the 'Category' of the corresponding element of EventDescriptionEventDetail property.
Works fine unless you have any VIEvents type "EventEx" - then, this 'research' in EventDescriptionEventDetail collection method fails, because there is more than one element of this type (there are 91 of them at the moment).
This led me to the next bit. It is similar to the previous method, but it handles EventEx events too:
## get the .Net View object of the EventManager (used for getting the event Category)$viewEventMgr = Get-View EventManager ## get some VIEvents (the last 100, as "-MaxSamples" is not specified) Get-VIEvent | %{ ## put the pipeline varible into another variable; get its type $oThisEvent = $_; $strThisEventType = $_.GetType().Name ## if this event is of type "EventEx" if ($strThisEventType -eq "EventEx") { $strEventTypeId = $oThisEvent.EventTypeId; ## get the EventInfo item (of type EventDescriptionEventDetail) whose "FullFormat" property begins with the EventTypeId of the VIEvent at hand, and get its "Category" property $strCategory = ($viewEventMgr.Description.EventInfo | ?{$strRegexPattern = "^$strEventTypeId\|.*"; $_.FullFormat -match $strRegexPattern}).Category } ## end if ## else, can just grab the EventInfo item whose "Key" is the same as this event's type else {$strCategory = ($viewEventMgr.Description.EventInfo | ?{$_.Key -eq $strThisEventType}).Category} ## add a NoteProperty "EventCategory" to this event $oThisEvent | Add-Member -MemberType NoteProperty -Name EventCategory -Value $strCategory -PassThru} | Select FullFormattedMessage, CreatedTime, EventCategory
It seems that the EventTypeId of the event returned by Get-VIEvent is included in the first part of the property FullFormat of elements EventDescriptionEventDetail with EventEx key, separate from the rest of the value by a vertical pipe. Thus, the EventTypeId of the VIEvents can be used to make a match on EventEx of events .net EventManager View object types to get the event 'category' (info, warning, error, user).
You can, of course, change the Select statements to choice/choose the pieces of information you want to export and then export to a file of data as you please.
How does do for you?
* The message has been edited by mattboren on April 5, 2011 - added line at the beginning of the second piece of code '$viewEventMgr = Get-view event Manager. It was already in the first room and assumes that the user has run the two parts in the same session, but added for completeness.
-
Look at a record events with get-vievent
How can I use get-vievent to see everything that follows?
-All exports of VMS in vCenter
-All exports of virtual machines in an ESXi host
-All downloads of files vmdk to a store of data using client operations or copy of Vmware on the vmdk from the dcui / ssh console?
The idea is to see every time a vmdk left the environment.
You can report export (EGGS or OVF) with the following
$start = (get-Date). AddHours(-1)
Get-VIEvent-Start $start - MaxSamples ([int]: MaxValue) |
where {$_-is [VMware.Vim.TaskEvent] - and $_.Info.DescriptionId - eq "VirtualMachine.ExportVmLRO"} |
Select CreatedTime,UserName,@{N='VM'; E={$_. UMM name}}, FullFormattedMessage,
@{N = 'Event'; {E = {$_.Info.DescriptionId}}
Download files through the browser data store does not all events as far as I know.
-
Events not shown in get-vievent
What types of events are NOT displayed in
Get-vievent?
For example, suppose that a user connects to a server ESXi directly, rather than connecting to vCenter Server. This ESXi server is managed by the vcenter Server. Everything is done on the ESXi server can still to report through
'
Get-vievent
the server vCenter Server?
What could be missing if I don't
Get-vievent - username 'ADDOMAIN\adusername '.
the server vCenter for this user?
Server ESXi and vCenter server have their own set of events.
As you can easily check with my Event-O-Matic script, when you connect to a server ESXi and vCenter server.
ESXi events, both there are connectivity, are copied to the vCenter by the vpxa service that runs on the ESXi.
So in theory you should, as far as I know, see all ESXi appearing in the vCenter events events & tasks
-
Getting VM event for some days
Hello
I wan to pull events for a particular virtual machine for the last 2 months. I want to know who made changes to the configuration of the VM (like adding disks, Flash, etc.). Also, this command gives a result for all virtual machines, but I'm looking for particular VM e.g.VM1. Let me know if any script or command in cli.
Thank you
vm2014
Right channel output to Export-CSV.
Get-VIEvent-beginning (Get-Date). AddMonths(-2) - MaxSamples ([int]: MaxValue)-entity (Get - VM someVM) | Export-CSV - NoTypeInformation ' VM - Events.csv.
-
Hello
I entered the following two functions in my shell powercli
Two functions I have installed function {Get-VMEvents
< #.
. Logbook
Get events for an entity or query all events.
. Description
This function returns the events for the entities. It is very similar to
cmdlet Get-vievent. Please note that get-VMEvent can handle 1 vm at a time.
You can't send picture of vms in this version of the script.
. Example of
Get-VMEvents 0All-types "VmCreatedEvent", "VmDeployedEvent", "VmClonedEvent".
He will receive all events of type "VmCreatedEvent", "VmDeployedEvent"
'VmClonedEvent '.
. Example of
Get-VMEvents-name 'vm1' - type 'VmCreatedEvent '.
Will be out of the events of creation of virtual machine: "vm1. It's faster than the vms piping is of
result of Get - vm. There is no need to use get - vm to move names to get-vmevents.
Yet, it is OK when you do, it will be just a little more slow < span class = "wp-smiley wp-emoji wp-emoji-blink of eye" title = ';') > ;) </span >
. Example of
Get-VMEvents-name 'vm1' - category 'WARNING '.
Will be out all events for vm: 'vm1. It is is faster than the names of piping of
cmdlet Get - vm. Category will get-vmevent to search only the defined category
events.
. Example of
Get - vm "vm1 | Get-VMEvents-types "VmCreatedEvent", "VmMacAssignedEvent".
Shows events for vm1 which will be regarding the events of creation,.
and events when when / what mac address is assigned
. VM parameter
This setting is a unique string that represents the name of the vm. He expects this single vm name
There in the virtual Center. Now in the first version of the script, it will only load a case
where there is 1 instance of vm selected name. In the future it will load multiple as
Well.
. Types of parameters
If none is specified, it will return all the events. If specified will return
Only the events with selected types. For example: "VmCreatedEvent."
"VmDeployedEvent", "VmMacAssignedEvent" "VmClonedEvent", etc...
. Category of a parameter
Possible categories are: warning, info, error. Please use this setting if you
you want to filter events.
. Setting all the
If you need to set this parameter, so command queries all events
Center Virtual Server virtual machines.
. Notes
NAME: VMEvents
AUTHOR: Grzegorz Kulikowski
LASTEDIT: 09/11/2012
DOES NOT? #powercli @ irc.freenode.net
. Link
# >
(param
[Parameter (ValueFromPipeline = $true)]
[ValidatenotNullOrEmpty()]
$VM,
[String []] $variétés.
[string] $category,
[switch] $All
)
$si = get-view ServiceInstance
$em is get-view $si. Content.EventManager
$EventFilterSpec = new-Object VMware.Vim.EventFilterSpec
$EventFilterSpec.Type = $types
{if ($Category)}
$EventFilterSpec.Category = $category
}
If {($VM)
$EventFilterSpec.Entity = new-Object VMware.Vim.EventFilterSpecByEntity
switch ($VM) {}
{$_-is [VMware.Vim.VirtualMachine]} {$VMmoref = $vm.moref}
{$_-is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl]} {$VMmoref = $vm. ExtensionData.moref}
default {$vmmoref = (get - view - ViewType virtualmachine-filter @{'name' = $VM}) .moref}
}
$EventFilterSpec.Entity.Entity = $vmmoref
$em. QueryEvents ($EventFilterSpec)
}
If {($All)
$em. QueryEvents ($EventFilterSpec)
}
}
function get-vmcreationdate {}
< #.
. Logbook
Gets if possible virtual machine created.
. Description
This function will return the object with information about the creation time, method, of months,.
creator of particular virtual machine.
VMname: SomeVM12
Createduserid: 10/08/2012 11:48:18
CreatedMonth: August
CreationMethod: cloned
Creator: office\greg
This function displays NoEvent property in case when your VC do not
more information on these specific events, or your vm events no longer have
entries for the subject being created. If your VC data base has more tension date it is no longer possible
you find this event.
. Example of
Get-VMCreationdate - VMnames 'my_vm1', 'My_otherVM '.
This will return items that contain date information of creating virtual machines with names
myvm1 and myvm2
. Example of
Get-VM-location 'Cluster1 | Get-VMCreationdate
This will return items that contain information created for virtual machines that are
Located in Cluster1
. Example of
Notice-EEG - viewtype virtualmachine - SearchRoot (get-datacenter "mydc") user.user | Get-VMCreationDate
This will return items that contain information created for virtual machines that are
located in the data center "mydc" container If you use this feature in an existing loop where you
having the cmdlet get-view virtual machines, you can pass them via pipes or as a parameter VMnames.
. Example of
$report = get-cluster "cl-01' | Get-VMCreationdate
$report | Export-csv c:\myreport.csv
Stores all reported creationtimes object in the array $report variable and export the report to a csv file.
You can also filter the report before you write in the csv file using select
$report | Where-Object {$_.} {CreatedMonth - eq "October"} | Select VMName, CreatedMonth
So that you see only the vms that have been created in October.
. Example of
Get-vmcreationdate - VMnames "my_vm1", testvm55
WARNING: my_vm1 is not found, typo?
VMname: testvm55
Createduserid: 05/10/2012 14:24:03
CreatedMonth: October
CreationMethod: NewVM
Creator: home\greg
In case when you receive virtual machine that is not appropriate in the infrastructure of yor, a warning is displayed.
You can always store the full text of the report in the $report variable, but it includes all the information on
dates of creation of the missing vm. A warning always only for your information there is
probably a typing mistake in the name of the virtual machine.
. Parameter VMnames
This parameter must contain objects of virtual machine or strings representing vm
names. It is possible to supply this function wiith VM objects coming from get - vm or
get - view.
. Notes
NAME: Get-VMCreationdate
AUTHOR: Grzegorz Kulikowski
LASTEDIT: 27/11/2012
DOES NOT? #powercli @ irc.freenode.net
. Link
# >
(param
[Parameter (ValueFromPipeline = $true, mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Object []] $VMnames
)
{in process
{foreach ($vm to $VMnames)
$ReportedVM = "" | Select VMname Createduserid, CreatedMonth, CreationMethod, creator
If ($CollectedEvent = $vm |) Get - VMEvents - types "VmBeingDeployedEvent", "VmRegisteredEvent", "VmClonedEvent", "VmBeingCreatedEvent" - ErrorAction SilentlyContinue)
{
If ($CollectedEvent.GetType ().) IsArray) {$CollectedEvent = $CollectedEvent |?} {{$_-is [vmware.vim.VmRegisteredEvent]}}
$CollectedEventType = $CollectedEvent.gettype () .name
$CollectedEventMonth = "{0: MMMM}" $CollectedEvent.CreatedTime f
$CollectedEventCreationDate = $CollectedEvent.CreatedTime
$CollectedEventCreator = $CollectedEvent.Username
Switch ($CollectedEventType)
{
"VmClonedEvent" {$CreationMethod = "Cloned"}
"VmRegisteredEvent" {$CreationMethod = "RegisteredFromVMX"}
"VmBeingDeployedEvent" {$CreationMethod = "VmFromTemplate"}
"VmBeingCreatedEvent" {$CreationMethod = "NewVM"}
default value {$CreationMethod = 'Error'}
}
$ReportedVM.VMname = $CollectedEvent.vm.Name
$ReportedVM.CreatedTime = $CollectedEventCreationDate
$ReportedVM.CreatedMonth = $CollectedEventMonth
$ReportedVM.CreationMethod = $CreationMethod
$ReportedVM.Creator = $CollectedEventCreator
} else {}
If ($?) {
If ($vm - is [VMware.Vim.VirtualMachine]) {$ReportedVM.VMname = $vm.name} else {$ReportedVM.VMname = $vm.} ToString()}
$ReportedVM.CreatedTime = 'NoEvent.
$ReportedVM.CreatedMonth = 'NoEvent.
$ReportedVM.CreationMethod = 'NoEvent.
$ReportedVM.Creator = 'NoEvent.
} else {}
$ReportedVM = $null
Write-Warning "$VM is not found, typo?
}
}
$ReportedVM
}
}
}
Now, if I use the first command
Get - vm testvm
I get a response of
Name PowerState Num CPU MemoryGB
---- ---------- -------- --------
Receiving TestVM 4 4,000
But if I do
Get-vmcreationdate testvm
he responds with
WARNING: testvm is not found. misspelling?
I can't understand why he says this?
What will be the final objective to query the server vcenter set and export a CSV of the creation of each day VM - is their an easier way to do it?
I was intending to use
get - vm | Get-VMCreationDate | Export-Csv-path "d:\\reports\vmcreationinventory.csv ".
But at the present time, each unique virtual machine is indicating "is not found."
Attached is an example with a virtual machine called gbvls
Although you may be better communicate with the author of these functions, from what I can tell, it seems to indicate that none of the specified events were found for these virtual machines.
You can check if there are targeted with the cmdlet Get-VIEvent ordinary events.
If you can see events, there could be a problem with the Get-VMEvents function.
$vmName = 'testvm '.
$tgtEvents = "VmBeingDeployedEvent", "VmRegisteredEvent", "VmClonedEvent", "VmBeingCreatedEvent".
$vm = get-VM-name $vmName
Get-VIEvent-body $vm - MaxSamples ([int]: MaxValue) |
Where {$tgtEvents - contains $_.} GetType(). Name}
-
Hello Luke,.
Instead of the select-object cmdlet, I would use format-table - Autosize. If I do this, I can only direct to cmdlet convertto-html I want. What is the trick here? I need an output formatted due to FullFormattedMessage.
$fileloc = "c:\error.csv".
$vievents = get-VIEvent-start (Get-Date). AddHours(-24)-Types 'mistake ' |
Select-object Createduserid, username, FullFormattedMessage |
Export-Csv-path $fileloc - NoTypeInformation - UseCultureThank you
You must use a Format-* cmdlet only as the last cmdlet in a pipeline. The Select-Object cmdlet is used to select only the properties that you want. To better keep this cmdlet. You can convert the output to html format with:
$a = "" Get-VIEvent -Start (Get-Date).AddHours(-24) -Types "Error" | Select-Object CreatedTime, UserName, FullFormattedMessage | ConvertTo-HTML -head $a -body "
VI Events Information
" | Out-File VIEvents.htm Start VIEvents.htmBest regards, Robert
-
Get-VIEvent "vSphere HA restarted virtual machine.
Hi score
Can someone help me complete this script
Get-Cluster 'test ' | Get - VM | Get-VIEvent | Where-Object {$_.} FullFormattedMessage-LIKE "{vSphere virtual machine rebooted HA *'} |" Select ObjectName,@{N="IP addr; E={($_. Guest.IpAddress)}}, Createduserid, FullFormattedMessage
Out put:
ObjectName IP addr Createduserid FullFormattedMessage
---------- ------- ----------- --------------------
VM1 05 - Sep - 14 16:14:29 vSphere restarted my virtual HA...
VM2 05 - Sep - 14 16:14:25 vSphere restarted my virtual HA...
VM3 05 - Sep - 14 16:14:25 vSphere restarted my virtual HA...
Failed to get the IP address on this script.
Thank you for giving if any good script to get vSphere HA restarted event when the host failure.
Try like this
Get-Cluster 'test ' | Get - VM |
Get-VIEvent |
where {$_.} FullFormattedMessage-match 'vSphere virtual machine rebooted HA'} |
Select ObjectName,@{N="IP addr; E = {(Get-vue-Id $_.)} {{Vm.Vm). Guest.IpAddress}}, Createduserid, FullFormattedMessage
Not sure property you are trying to achieve with ObjectName.
-
Filtering some results in Get-VIEvent
How would be to filter the results of Get-VIEvent or other specific keywords in the FullFormattedMessage, or by the MessageInfo property?
I'm trying to use Get-VIEvent to get a list of warning and error events and want to filter the "insufficient result of RAM video.
I am trying to filter either by the insufficient "vidéo RAM" text in the property of FullFormattedMessage, or the result of "{msg.svgaUI.badLimits}" in the MessageInfo property.
Thanks in advance for any help.
Hello, aydeisen-
You can use a statement Where-Object to filter the events as you wish. As:
Get-VIEvent | Where-Object { ($_.FullFormattedMessage -like "*Insufficient video RAM*") -or ($_.MessageInfo | ?{$_.id -like "*msg.svgaUI.badLimits*"})} ## end where-object
This verifies VIEvents whose FullFormattedMessage property is as the given string, or whose MessageInfo property (which is zero or more objects of VirtualMachineMessage ) is an VirtualMachineMessage object with the id as the given string property.
Of course, you will use the other Get-VIEvent settings for changing the scope of the events gathered initially (for a given entity, a time limit given, maxSamples, etc.). How does do for you?
-
I'm trying to generate a list of all users who are connected. I have this command and it works, but I would exclude 1 or more users of this list, which is "root".
Here is the command I use.
$events = get-VIEvent - MaxSamples 1000
foreach ($event in $events) {if ($event.fullFormattedMessage - match '(.*)@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b connected the user') {Write-Host ('User' + $matches [1] + "" connected to: "+ $event.createdTime")}}
Hi, mchunger,
This should work for you, if you know the names you want to exclude:
$excl = @(«root», «admin», «dcui»)
foreach ($event in $events) {if ($excl - notcontains $event.username) {if ($event.fullFormattedMessage - match '(.*)@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b connected the user') {Write-Host ('User' + $matches [1] + "" connected to: "+ $event.createdTime")}}}
Kind regards
Ogniana
-
Don't PowerCLI v5 changes that behaves in the way that get-vievent?
Hi all
I just installed v5 powerCLI and some scripts I was using don't work anymore.
the get-vievent-start (get-date command).adddays(-2) that I have used to analyze events in the course of the last 2 days, is now back only a few events, all of the current day.
is - anyone notice the same behavior?
Hello, nicolasbouyssy-
Hmm, strange. So, if you run the line of your script that gets the desired events and count the number of items that it returns is - this superior to the default value of 100? In other words, something like:
(Get-VIEvent -Start (Get-Date).AddDays(-2)).Count
I understand wanting to have things run fast. Can possibly restrict you the events that you retrieve by specifying an array of entities for which to get the events (using parameter - entity), either by limiting the event types with the parameter - Types (to represent types of error, Info, or Warning)?
Regarding, "unless it is smart enough to stop navigation when the date is reached" - Yes, it must be the behavior when you use the MaxSamples parameter with - Start - it will return up to MaxSamples number of events, but none is older than the specified start date. So, if there are 100000 events, but only 2200 in the past two days, specifying for MaxSamples 100000 with a start of two days should return only 2200 events.
As for fixing the MaxSamples number to cover all events - I assumed that to be sure that you get all you can, you can use the maximum value for MaxSamples. It's a [int32], whose maximum value is 2,147,483,647 (which is (2 ^ 31) - 1). So to be sure you have found all the events gave as you can, you can use this maximum value for MaxSamples, as such:
Get-VIEvent -MaxSamples 2147483647 -Start (Get-Date).AddDays(-15)
Or, using mathematics (maybe for readability):
Get-VIEvent -MaxSamples ([Math]::pow(2,31) - 1) -Start (Get-Date).AddDays(-15)
But, filtering of events on some of the other things mentioned above (type, entity) apparently is a good idea before the entry to get about 2 ^ 31 events...
-
Get-VIEvent command line options
Hello list,
Options of I have a question about the command line for Get-VIevent. I need to get the logs between a given time limit. I'll use this command in a script. If I can make use of Get-Date command output to - Start - Finish settings.
I have to get the logs between a given time limit. for example I need newspapers between 16:00 to 17:00 on the same day. for that I do use Get-Date command output?
Thank you
Ghislain
Ghislain wrote:
This way to grep for a particular string. I know there is an option called "findstr". can you please cite the use of this option of findstr?
There are a few (dozen) different ways to approach this problem in PowerShell. I hope these examples help:
PS > $a = Get-VIEvent PS > $a | group { $_.GetType().BaseType } Count Name Group ----- ---- ----- 20 VimApi.AlarmEvent {13875, 13874, 13873, 13872, 13853, 13852, 13846, 13845, 13809... 8 VimApi.SessionEvent {13871, 13870, 13869, 13823, 13816, 13815, 13813, 13812} 65 VimApi.VmEvent {13868, 13867, 13866, 13865, 13864, 13863, 13862, 13861, 13860... 2 VimApi.HostEvent {13821, 13819} 3 VimApi.Event {13820, 13818, 13784} 1 VimApi.GeneralEvent {13817} 1 VimApi.CustomFieldDefE... {com.icomasoft.PowerScripter.script} PS > $a | Where-Object { $_.key -eq 13875 } source : VimApi.ManagedEntityEventArgument entity : VimApi.ManagedEntityEventArgument from : gray to : green alarm : VimApi.AlarmEventArgument key : 13875 chainId : 13845 createdTime : 12/7/2008 11:17:27 AM userName : datacenter : VimApi.DatacenterEventArgument computeResource : VimApi.ComputeResourceEventArgument host : VimApi.HostEventArgument vm : VimApi.VmEventArgument fullFormattedMessage : Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green dynamicType : dynamicProperty : PS > $a | ? { $_.fullFormattedMessage -match "memory" } | select -first 5 | ft key, full* -auto key fullFormattedMessage --- -------------------- 13875 Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green 13873 Alarm Virtual Machine Memory Usage on vcenter.halr9000.com changed from Gray to Green 13853 Alarm Virtual Machine Memory Usage on vcenter.halr9000.com changed from Green to Gray 13846 Alarm Virtual Machine Memory Usage on openfiler changed from Green to Gray 13809 Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green
[PowerShell MVP |] [ https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], the VI Toolkit forum moderator
Author of the forthcoming book: VMware Infrastructure Management with PowerShell
Co-host, PowerScripting Podcast (http://powerscripting.net)
Need help in General, other than VMware PowerShell? Try the PowerShellCommunity.org forums
-
How to get the event when we change our simcard in BB device
Hi all
Please, someone tell how to get the event or any listener method that can automatically called when we change our SIM card device.
Thanks in advance,
TEJ
Hi Tej,
I came across some post, which may be useful for you
http://supportforums.BlackBerry.com/T5/Java-development/is-SIM-ID-really-exist/m-p/54407#M5954
-
Get - vm | Get-vievent email html output
Hello world
I am having trouble pushing results table in an object and then adding the members of the object to an array. I have had success using the slot method in the past, but I've only tried (previously) with a cmdlet. In the example below, I'm piping several cmdlets. Basically, $vms outputs very well, but I can't get any instantiated table to fill later. The $mainArray will always send as null in the email. Any ideas? I really don't want to get vievent in the foreach loop, as it will really slow down the query.
SE connect-viserver test.testdomain.com
$mainArray = @)
$userArray = @)
$timeArray = @)
$msgArray = @)
$CDT = get-Date
$vms = get - VM | Get-VIEvent-Types of information - start $CDT. AddDays(-30)-finishing $CDT | Where {$_.} GetType(). Name - eq "VmBeingDeployedEvent" - or $_. GetType(). Name - eq "VmCreatedEvent" - or $_. GetType(). Name - eq "VmRegisteredEvent"} | Select the username, Createduserid, FullFormattedMessage | Format-Table - AutoSize
foreach ($vm to $vms)
{
$username = $vm. Username
$createdTime = $vm. Createduserid
$msg = $vm. FullFormattedMessage
$userArray += $username
$timeArray += $createdTime
$msgArray += $msg
}
For ($i = 0; $i - lt $userArray.Count; $i ++)
{
$item = new-Object PSObject
$item | Add-Member-type NoteProperty-Name "UserName" - value $userArray [$i]
$item | Add-Member-type NoteProperty - name "time created" - value $timeArray [$i]
$item | Add-Member-type NoteProperty-Name 'Message' - value $msgArray [$i]
$mainArray += $item
}
"$Head = @".
< style >
TABLE {border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse ;}}
TH {border-width: 1px; padding: 3px; border-style: solid; border-color: black; background-color: #6495ED ;}}
TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black ;}}
< / style >
"@
# #begin send e-mail section.
$comp = get-wmiobject win32_computersystem
$mailFrom = $comp.name
$FromAddr = $mailFrom + "@testdomain.com.
$ToAddr = " " [email protected] "" "
$Subject = "Virtual machines created in the last 30 days"
$SMTPServer = "smtp.testdomain.com".
$Body = $mainArray | ConvertTo-Html-head $Head | Out-string
Send-MailMessage-to $FromAddr - to $toAddr - subject $Subject - body ($body) - BodyasHtml - SmtpServer $SMTPServer
disconnect-viserver-confirm: $false
Why if complicated, what follows should give the same result.
SE connect-viserver test.testdomain.com
$mainArray = @)
$CDT = get-Date
$mainArray = get - VM | Get-VIEvent-Types of information - start $CDT. AddDays(-3)-finishing $CDT | Where {$_.} GetType(). Name - eq "VmBeingDeployedEvent" - or $_. GetType(). Name - eq "VmCreatedEvent" - or $_. GetType(). Name - eq "VmRegisteredEvent"} |
Select @{N = 'Username'; E={$_. User name}}.
@{N = "time created"; E={$_. Createduserid}},
@{N = 'Message'; E={$_. FullFormattedMessage}}
"$Head = @".
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
"@
# #begin send e-mail section.
$comp = get-wmiobject win32_computersystem
$mailFrom = $comp.name
$FromAddr = $mailFrom + "@testdomain.com.
$ToAddr = "[email protected]".
$Subject = "Virtual machines created in the last 30 days"
$SMTPServer = "smtp.testdomain.com".
$Body = $mainArray | ConvertTo-Html-head $Head | Out-string
Send-MailMessage-to $FromAddr - to $toAddr - subject $Subject - body ($body) - BodyasHtml - SmtpServer $SMTPServer
disconnect-viserver-confirm: $false
-
Get-VIEvent to find the name of vm?
Hello
Is it possible to get the name of the vm get-vievent?
I'll try to find all the VMS created in the last day (easy), then get - vm... basic idea...
Get-VIEvent - maxsamples 20000 - Start (Get-Date). AddDays(-1) | where {$_.} GetType(). Name - eq "VmBeingDeployedEvent | VmCreatedEvent | VmRegisteredEvent | VmClonedEvent"} | Select the username, Createduserid, FullFormattedMessage |% {get - vm $vm}Thanks for the help!
I don't watch carefully your Where clause, it should be like the code above.
Please try like this.
Maybe you are looking for
-
Should I remove the applications that have been pre-installed on my Mac I ever use – like "GarageBand", etc.. ? This will make my Mac last boot like, faster, or is it not important?
-
IIS 7.5, the NETBIOS command limit has been reached
We use IIS services and media to stream videos. It comes to our dedicated streaming server. On rush hour, an error showed by saying 'the NETBIOS command limit has been reached. More info on platform: IIS version is 7.5 OS version is Windows Server 20
-
I see nothing in the Ko or FAQ for help. as usuall, I get an error that nobody has seen before. I tried the following: delete the windows temp file restarting the computer; reloaded the file vcrdist.msi
-
How is it that I don't have a copy of my system opating (windows 7 Home premium sp1) disk? I don't have to buy another copy of the disk to use.
-
As soon as the notebook starts up, it gives an error "system BIOS with a shadow.
Now every time I start up computer laptop I get the error system BIOS shadowed... I HAVE SAMSUNG NOTEBOOK R439