Report snapshot. ssmail.txt output

Hey everyone, trying to make a report snapshot and some return values in a .txt document so I can send by e-mail. I would like to return the virtual machine creation date and the creator's username.

Everything works fine, except my ssmail.txt output. He wants only to return the user name of the last person who created a snapshot, even if its on a different virtual computer.

$myVMs = get - VM

$VMsWithSnaps = @)

{foreach ($vm to $myVMs)

$vmView = $vm | Get-View

If ($vmView.snapshot - not $null) {}

Write-Host "VM $vm has a snapshot.

$SnapshotEvents = get-VIEvent-body $vm - type info - MaxSamples 1000 | Where {}

$_. FullFormattedMessage.contains ("Create virtual machine snapshot")}

try {}

$user = $SnapshotEvents [0]. Username

$time = $SnapshotEvents [0]. Createduserid

} catch {} [System.Exception]

$user = $SnapshotEvents.UserName

$time = $SnapshotEvents.CreatedTime

}

$VMInfo = "" | Select 'VM', 'CreationDate', 'user '.

$VMInfo. "" VM "= $vm. Name

$VMInfo. "' CreationDate ' = $time

$VMInfo. "" User "= $user

$VMsWithSnaps += $VMInfo

Get - VM | Select-Object - ExpandProperty name | Out-file "C:\scripts\VMList.txt."

Get-Snapshot - VM (Get-Content C:\scripts\VMList.txt). Select-Object VM, name, creation, $user | Format-List | Out-file C:\scripts\ssmail.txt

}

}

$VMsWithSnaps | CreationDate sorting

*****************************************************

It's out of ssmail.txt:

VM: Lab - vCO VM

Name: test

Created on: 07/08/2014-14:01:38

Adam:

VM: Lab - vCO VM

Name: test1

Created on: 11/08/2014-13:18:39

Adam:

VM: Lab - vCO VM

Name: test2

Created on: 12/08/2014-09:38:36

Adam:

VM: Test VM

Name: test

Created: 13/08/2014-09:49:42

Adam:

********************************************************

It seems that the last person to create a snapshot will have their user name filled with each snapshot release. For example: he says 'Adam' created all snapshots, but "John" had created the first 3 and 'Adam' the last of them.

Thank you.

I don't understand why you have the Get - VM and Get-snapshot at the end of the script.

Try like this (I've simplified a little other things as well)

$myVMs = get - VM

{foreach ($vm to $myVMs)

Get-Snapshot - $vm VM | Tri-objet-property CreationDate-descending | Select - 1 first | %{

Write-Host "VM $vm has a snapshot.

$SnapshotEvents = @(get-VIEvent-entité $vm-tapez info-MaxSamples ([int]:: MaxValue) |)

Where {$_.} FullFormattedMessage.contains ("Create virtual machine snapshot")})

$_ | Select-Object VM,Name,@{N="Created; E = {$SnapshotEvents [0].} CreatedTime}},@{N="User '; E = {$SnapshotEvents [0].} User name}} |

Format-List | Out-file C:\ssmail.txt-ajouter

}

}

Tags: VMware

Similar Questions

  • helps the report snapshot in full size conversion

    Hi people,

    Just start with PowerCLI and restored a scipt to send me a list of snapshots (I realize there are a lot of scripts that preset). the script works as expected, but the variable SizeMB includes 19 and 20 decimals, which makes it a little difficult to read.

    line of script in question:

    $Report = get - vm | Get-snapshot | Select vm powerstate, name, sizemb | ConvertTo-Html-head $a | Out-string

    example of output:

    VM

    PowerState

    Name

    SizeMB

    Test cluster

    PoweredOff

    Before installing the drivers

    432.1879596710205078125

    MAX - DEV

    Receptor

    06/03/2013

    5201.38588237762451171875

    full script below. can anyone suggest an easy way to round or truncate the size of snapshot to a whole number?

    Thank you

    Alex

    Add-pssnapin VMware.VimAutomation.Core
    SE connect-VIServer foo.bar.com
    $vCenterSettings = get-view-Id "OptionManager-VpxSettings.
    $MailSender = ($vCenterSettings.Setting |) Where-Object {$_.} Key - eq "mail.sender"}). Value
    $MailSmtpServer = ($vCenterSettings.Setting |) Where-Object {$_.} Key - eq "mail.smtp.server"}). Value
    $a = '< style >.
    $a = $a + "BODY {font family: Verdana, Arial, Helvetica, without serif;} '. do-size: 11; "{do-color: #000000}.
    $a = $a + "TABLE {border-width: 1px;}. border-style: solid; border-color: black; border-collapse: collapse ;} »
    $a = $a + "TH {border-width: 1px;}. padding: 0px; border-style: solid; border-color: black; "{background-color: #04B45F}.
    $a = $a + "TD {border-width: 1px;}. padding: 0px; border-style: solid; border-color: black; "{background-color: #BCF5A9}.
    $a = $a + ' < / style >.
    $Report = get - vm | Get-snapshot | Select vm powerstate, name, sizemb | ConvertTo-Html-head $a | Out-string
    ' Send-MailMessage-to $MailSender-to ' [email protected] "-subject" SoE vCenter report snapshot "-$Report - BodyAsHtml - smtpServer $MailSmtpServer of body "
    Output

    Try to change this line

    $Report = get - vm | Get-snapshot | Select vm powerstate, name, sizemb | ConvertTo-Html-head $a | Out-string

    in this

    $Report = get - vm | Get-snapshot | Select vm,powerstate,name,@{N="sizemb; E = {[math]: tour ($_.)} (SizeMb, 2)}} |

    ConvertTo-Html-head $a | Out-string

    With a calculated property, you can make calculations or changes on the property that you want to display

  • automatic scheduling of the report and send the output to the user by e-mail

    Hello
    Please I need scheduled report and send the output by email in discoverer. Please can someone help how to achieve this?

    Hello

    Yes, do you that.

    Please see Metalink Note 373812.1 how the schedule of reports to run at a given time while automatically the output electronics

    Thank you
    Fati

  • Txt output using a web program (OAS 10 g) unit

    Hello world.

    I have a c/s (6i) report that generates a txt file in a program unit using the TEXT_IO package. I need to move this report to web (reports 10g) and its publication in OAS 10 g. I did (without the generation of text file), I can see the report on the browser to Format PDF and works very well... but I still have a problem... When I use Text_io package, c/s of the report in 10g version works one generates the output.txt file, but when I move it to the web, I got an error in the front trigger report (in which I invoke the program unit sp_generate_txt)

    I looked around for a solution and I found use the webutil package, but as you know, webutil package is usable only in the forms.

    Any ideas on how I can fix this?

    Hello

    TEXT_IO can be used in the reports on the web.

    The difference with Client/Server is the fact that the file created by TEXT_IO will be created on the server 'medium level' and not on the Client.

    Concerning

  • Report snapshot including Snap owner/creator

    I have a script that I run every day to declare open shadow.  This is a script I found online, but then realized that we wanted to add the owner for the wink to the information.  Again, I found little code online and was able to add in the script, but he still does not seem to properly make the owner.  Any help would be greatly appreciated.

    Here is the corresponding code.  I added some parts that enter data using Get-VIEvent and then post it in (Description and CreatedBy).  The problem is that it doesn't seem to be reliable.  The owner sometimes comes in white, and sometimes it shows one user other than who actually took the snapshot.  I'm not great PowerShell and I wanted to know if someone can suggest what is wrong in the code?  I'll also join the original inside code that is supposed to shoot instant owner that I joined the first script.  When I run which, in itself, he either said the event is not in the database, or sometimes it is correct when the main script is wrong, or watch a user empty.

    I also read that there is a more reliable than VIEvents way to get the owner of the hanging.  I found a code on this forum, but I was unable to understand how to integrate properly.

    # Add plugin VMWare PowerShell and connect to vCenter

    Add-pssnapin VMware.VimAutomation.Core

    Set-executionpolicy remotesigned - confirm: $false

    Game-PowerCLIConfiguration - ignore InvalidCertificateAction - confirm: $false

    to connect-viserver < viserver >

    # create table to capture info VM snapshot

    $vmtable = New-Object system. Data.DataTable "VMTable".

    $col1 = New-Object system. Data.DataColumn VM, ([string])

    $col2 = New-Object system. Data.DataColumn Snapshot ([string])

    $col3 = New-Object system. Data.DataColumn SizeMB, ([string])

    $col4 = New-Object system. Data.DataColumn Created, ([string])

    $col5 = New-Object system. Data.DataColumn Description,([string]) #Added by me

    $col6 = New-Object system. CreatedBy,([string]) #Added by me Data.DataColumn

    $vmtable.columns.add ($col1)

    $vmtable.columns.add ($col2)

    $vmtable.columns.add ($col3)

    $vmtable.columns.add ($col4)

    $vmtable.columns.add ($col5) #Added by me

    $vmtable.columns.add ($col6) #Added by me

    #examine all the VMS in vCenter, if the snapshot has been found - adding to the table

    ForEach ($vm in (Get - VM |)) Sort - Object - property name))

    {

    ForEach ($snapshot in (Get-Snapshot - VM $vm. Name | Sort - Object - property name))

    {

    #$snapevent is how we get the event so that we can see wink creator.  Other variables can be used here.  Notes at the end of

    $snapevent is get-VIEvent-entity $snap. VM-Types of information-finishing $snap. Created MaxSamples - 1 | Where-Object {$_.} FullFormattedMessage - imatch ' task: create instant virtual computer "}"

    $created = - $snapshot split. Created

    $row = $vmtable. NewRow()

    $row. VM = $vm. Name

    $row. Snapshot = $snapshot. Name

    $row. SizeMB = "{0:N0}" f $snapshot. SizeMb

    $row. Created = $created [0]

    $row. Description = $snapshot.description #Added by me

    $row. CreatedBy = $snapevent. Username #Added by me

    $vmtable. Rows.Add ($row)

    }

    }

    #SnapEvents notes:

    #foreach ($snap in Get - VM |) Get - Snapshot)

    #{$snapevent = get-VIEvent-entity $snap. VM-Types of information-finishing $snap. Created MaxSamples - 1 | Where-Object {$_.} FullFormattedMessage - imatch ' task: create instant virtual computer "}"

    #if ($snapevent - not $null) {Write-Host ("VM:"+ $snap. ")} VM + ".." «Snapshot ' "+ $snap +" "created the"+ $snap. "» Created.DateTime + 'by' + $snapevent. (Nom d'utilisateur + ".")}

    #else {write-Host ("VM:"+ $snap. ")} VM + ".." «Snapshot ' "+ $snap +" "created the"+ $snap. "» Created.DateTime + ".." This event is not in vCenter events database")}}

    #

    #Output example output:

    #VM: DC2DC001. Snapshot ' pre - 5.1.2upgrade' created July 28, 2013 07:10:26 by vStrong.info\win8user.

    #VM: DC1DC001. "Pre 5.1.2a upgrade" snapshot created July 28, 2013 07:51:24 by vStrong.info\win7user.

    #VM: DC2APP001. Snapshot "to be resolved before" created on 2 August 2012 14:29:19. This event is not in the database of the vCenter events

    One of the reasons why you empty, could be that the timestamp of the event is not 100% identical to the timestamp of the snapshot.

    Alan SnapReminder , we add a short interval before and after snapshot creation time.

  • Snapshot of information output in html format

    Hello

    I have this beautiful oneliner to show some information snapshot:

    ' Get - VM | Get-Snapshot | SELECT name, Description, VM, SizeMB.

    I want to get this output and output to an html file.

    Is it possible to do that?

    Thank you

    Erik

    Since you have access to the .net PowerShell functions, you can make

    Get - VM | Get-Snapshot |

    Select VM,Name,Description,@{N="SizeGB; E = {[math]: tour ($_.)} {{SizeGB, 0}} |
    ConvertTo-HTML | Out-file C:\Scripts\Test.htm

  • Unable to find the id of the statspack report snapshot in Oracle 9.2.0.4

    Hello guys,.

    When I run @?/rdbms/admin/spreport.sql I am not able to see any id snapshot. I see all the values as #.

    Please find below the output, I get after I run @?/rdbms/admin/spreport.sql

    ========================================================================

    August 6, 2013 22:007
    August 6, 2013 23:007
    August 7, 2013 00:007
    August 7, 2013 01:007
    August 7, 2013 02:007
    August 7, 2013 03:007

    Specify the start and end snapshot Ids

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Begin snapshot Id specified:

    Enter the value for end_snap:

    ============================================================================

    Oracle version is 9.2.0.4.0

    I checked the tables ' stats$ snapshot and stats$ database_instance ', here too, I can see instant as id #.

    Please suggest.

    You need to edit $ORACLE_HOME/rdbms/admin/sprepins.sql, find a line something like

    column snap_id format 99999990 heading 'Snap Id';
  • SPA112 / SPA122 Report rule - Delta / status outputs

    Hello

    I played with the rule of the report and the documentation is not very clear regarding the two report options:-delta and - status

    If I set the rule report [-status]http://myserver/posthandler.php, I see the application to come, but the content of the POST is the real configuration (flat profile) instead of (dish-State) file. This also applies when you use the option - delta

    I use 1.3.1 to test, but I'm not 1.3.2 probably does not work as well.

    Anyone ever been able to generate a delta or get the ATA status.xml file content? I can get the URL (http://my_ata_ip/admin/status.xml), but would be nice to do remote too.

    Thank you

    Benoit

    It is an old and chaotic Guide version. But even here, they mention the status and delta is only supported on the version of the firmware, you do not use (because it is not available for SPA112).

    Well, mark the answer as correct (if we consider that it is correct), please. It will help others to find solutions.

  • How do I get a txt output in a column?

    Do not know and can not find any where and how to get the result in a column in a dynamic textfield

    instead of getting the output that is

    OUTPUT1 output2, output3, etc.

    I would like to have as

    Output 1

    output2

    Output3

    but I don't know how to make returns in flash - php/n

    can someone answer my question "simple."

    Thanx

    Try \n, not/n and you place a string ('\n'), where you want a new line.

  • Run two reports, but generate output

    I have developed two reports, one is a detail (portrait style) and another is a synthesis report (landscape). Now, I need to provide an option that will run reports but display the output in a single document (the document must contain the details and analytical content).

    Ideal scenario would be to call the report one after the other, but the output in a capture file, but I don't know if it is possible in the reports.

    Any help is appreciated. Thanks in advance.

    Sundar

    go to the Navigator object, expand the model layout, you would see the three Sections, header, hand and trailer. Use two of them to your needs.

  • Apex can we download the reports in .txt format?

    can we download the reports in Apex .txt format? because only word, excel, html, xml is given as an option, but I want in text format...

    Hello

    Excel is csv you can read with a text editor. No you want?
    In an interactive report you can not give an extension with it (happens automatically), but in a normal report, you can call ex .txt which will cause a text editor open the file automatically.

    Kind regards
    Dimitri
    ----------------------------------
    http://dgielis.blogspot.com/
    http://www.apex-evangelists.com/
    http://www.apexblogs.info/

  • Oracle reports XML-&gt; model RTF in XML Publisher output

    Hello

    Is it possible to run the output of a report from Oracle (formerly, made with the report writer) reports through the postprocessor output for get templated RTF PDF?

    The report is already out well-formed XML and I can use the Plugin of Word XML Publisher to turn it into a PDF file. However, I want to 'Set', 'concurrent demand' such as the XML is automatically transformed into a PDF file.

    I guess it would be an another "executable" as XDODTEXE who do that?

    -Johan

    Hi Johan

    Check out the following

    http://www.Oracle.com/technology/products/XML-Publisher/docs/XMLEBSRep.PDF

    Departure from the last demo (white image) here

    http://www.Oracle.com/technology/products/XML-Publisher/demoshelf/shelf.html

    Tim

  • Several numerical limit hide the exits "Unused" in the test report

    Hello

    I have a question about several limit test digital and output report in ascii txt format:

    Example of a measure, that's what I see in the txt file:

    Measure [74]:
    Limits:
    Low: 4.75
    Top: 5.25
    LowExpr: "
    HighExpr: "
    Units: V
    Comparison type: FROZEN (> =)<>
    CompExpr: "
    UseCompExpr: false
    Data: 5
    Status: passed

    Is there anyway I can hide or "understand" the unused portion of the output?  In this case I have LowExpr, HighExpr, CompExpr and UseCompExpr.  It will be cleaner and easier to navigate... basically this report:

    Measure [74]:
    Limits:
    Low: 4.75
    Top: 5.25
    Units: V
    Comparison type: FROZEN (> =)<>
    Data: 5
    Status: passed

    Kind regards

    Mike

    You're probably missing an indicator which is supposed to be there for some properties (i.e. PropFlags_DontCopyToResults). I don't see enough detail in your screen to see why this is happening, but if you enlarge the column in the middle or mailed this that all expressions are you using, I might be able to see what is happening. You can manually / programmatically readd this indicator for some properties, but it should really be configured by default on the expr properties already so I don't know why it isn't in your use case. The steptype sets the flag when running on the LowLimit and HighLimit are used as necessary for the case in which only one or no limit. It is generally expected the flag already set the other properties in need at the time of publishing.

    You can view the source code at:

    TestStand\Components\StepTypes\CommonSubsteps\

    to see how the type of step limit multinumeric sets the flag.

    Hope this helps,

    -Doug

  • Report guest VM

    I need a PowerCLI script that can generate a VM report in a txt file on the disc VM, CPU, memory, and Snapshot repoting.

    Thank you

    This new version of the script gives you snapshot size and space in MB used:

    Get-VM | `
      Select-Object Name,@{N="UsedSpaceMB";E={[math]::Round($_.UsedSpaceGB*1KB,0)}},NumCpu,MemoryMB,
        @{N="SnapshotSizeMB";E={[math]::Round(($_ | Get-Snapshot | Measure-Object -Property SizeMB -Sum).Sum,0)}} | `
      Format-Table -AutoSize | Out-File -FilePath VMsReport.txt
    
  • HTML report

    The necessary assistance in the code with the formatting in the HTML report with color like this below coding below.

    If the creation date is earlier than 3 days the line should be the color red, even if there are more than 2 yellow days and 1 day or more with the color green.

    Also, is it possible to include the size of snapshot and description in the report.

    #############################################################################################

    $stamp = get-date - f jjmmmaa-hhmmss
    SE connect-VIServer $vcservers - Credential $cred

    $before = @)
    $SnapReport = "C:\Daily_Reports\Snapshots\Reports\Snapshots-Report-$stamp.html".

    #get vm views for all virtual machines with pressure button
    Notice-EEG - ViewType virtualmachine. where {$_.snapshot - not $null} | {foreach}

    $snaptree += $_.snapshot.rootsnapshotlist
    $before = $snaptree | Select @{"n" = "VMName";  {'e' = {$($(get-viobjectbyViView-moref_$_.vm).name)}}, @{"n" = "SnapName";  {'e' = {$_.name}}, @{"n" = "Created"; {'e' = {$_.createtime}}
    }

    $a = '< style >.
    $a = $a + "TABLE {border-width: 1px;}. border-style: solid; border-color: black; border-collapse: collapse ;} »
    $a = $a + "TH {border-width: 1px;}. padding: 0px; border-style: solid; border-color: black ;} »
    $a = $a + "TD {border-width: 1px;}. padding: 0px; border-style: solid; border-color: black ;} »
    $a = $a + ' < / style >.

    $header = "< H1 > pending VM snapshot: $stamp < / H1 >.
    $title = "Vmware Snapshots reports"

    $before | ConvertTo-Html-head $a - body $header - title $title | Out-file $SnapReport

    #################################################################################################

    I took the method Chris gave to color the output and added size and description columns.

    Take a peek inside

    #############################################################################################  $stamp = get-date -f ddMMMyy-hhmmss # Connect-VIServer $vcservers -Credential $cred
    $before = @()
    $SnapReport = "C:\Snapshots-Report-$stamp.html"
    #get vm views for all vms with snapGet-View -ViewType virtualmachine | where { $_.snapshot -ne $null } | foreach {
        $snaptree += $_.snapshot.rootsnapshotlist
    }
    
    $a = ""
    $header = "

    Pending VM Snapshots :: $stamp

    "$title = "Vmware Snapshots Reports" $now = Get-Date$before = $snaptree | %{ $vm = get-viobjectbyViView -moref $_.vm $age = ($now - $_.createtime).Days if($age -gt 3){ $code = "red" } elseif($age -gt 2){ $code = "yellow" } else{ $code = "green" } $dateHtml = '

    ' + $_.CreateTime + '

    ' $_ | Select @{N="VMName";E={$vm.name}}, @{N="SnapName";E={$_.name}}, @{N="Created";E={$dateHtml}}, @{N="Description";E={$_.Description}}, @{N="SizeMB";E={(Get-Snapshot -Name $_.Name -VM $vm).SizeMB}} } $before | ConvertTo-Html -head $a -body $header -title $title | `foreach {$_.replace("<","<").replace(">",">")} | Out-File $SnapReport #################################################################################################

Maybe you are looking for

  • Start the asynchronous call brutal Typedef Bug

    There is a nasty bug which I think is the cause of many anomalies weird I see with the events of the user, like where some get fired and if I probe the refnum of the event on a VI that was launched using the asynchronous call node start I get some we

  • Vista won't start after the last update of Silverlight - restarts constantly

    I installed the latest version of Silverlight from Microsoft Update, July 21.  There are 2 updates, but the other would not move.  My computer worked nomally and later when I stopped it, I got the "Configuring updates... do not turn off your computer

  • Untitled - stopped working

    What does that mean? and how can I solve this problem? From the other thread: http://answers.microsoft.com/en-us/windows/forum/windows_vista-networking/untitled-has-stopped-working/767e3db9-f0de-496a-bfc3-b216952ea7ae Title: Untitled - stopped workin

  • How can I reinstall Vista Home Premium?

    I want to reinstall Vista Home premium in my lobtop. Help me please

  • Cannot access Windows 7 Desktop as PC stuck in safe mode

    my daughter gave me his old model. She gave me her password to access to comp. somehow something has changed, now I can only run in safe mode, how do I reset password? Can't access desktop on my dell windows 7. How can I reset password?-Original titl