using snapshot script

Most the script below for list of snapshots is spent for me (I made a few small changes) and it works fine except that it does not list the creator of the snapshot, but rather as the creator of the last snapshot even if there is not, instant vDP, for example.  In my opinion, it's how the Get-VIEvents is called instead to get the instant creator of the command get-snapshot.

Is anyone able to point me in the right direction, or use another method to find the instant creator?

Thank you.

$myVMs = get - VM

$VMsWithSnaps = @)

{foreach ($vm to $myVMs)

$vmView = $vm | Get-View

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

$snapsize = get - vm $vm | Get-snapshot | Select @{N = "SizeMB"; E = {[Math]: tour ($_.)} SizeMb)}}

$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', 'SizeMb.

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

$VMInfo. "' CreationDate ' = $time

$VMInfo. "" User "= $user

$VMInfo. "" SizeMb ' = $snapsize. SizeMb

$VMsWithSnaps += $VMInfo

}

}

$VMsWithSnaps | Sort CreationDate | FT-auto

After searching around on google, original screenplay seems to be:

Find photos of the virtual machine with PowerCLI | A Sysadmin notes

I've written a script before, which I'll post an article from below, makes you need TO get the name of the creator instant it involves using the API to get the saved task when the snapshot was created, (all times by obtaining the snapshot task of creating for the relevant VM within 5 seconds of the snapshot).  The script to see this section in context here is http://davotronic5000.co.uk/blog/updated-script-to-monitor-snapshots-in-vsphere/.  The part that gets the creators of snapshot is called:

Write-Verbose"Getting list of Old Snapshots"

   $OldSnapshotList= $SnapshotList | Where {$_.Created-LE(Get-Date).AddDays(-$AlertOlderThan)}

   IF($OldSnapshotList-ne$null)

       {

       Write-Verbose"Getting Additional Snapshot Details"

       #Open report array

       $Report= @()

       $SnapUser= ""

       FOREACH ($Snapshot in $OldSnapshotList)

           {

           #Use Task log SDK to get the user who created the Snapshot

           $TaskMgr = Get-View TaskManager

           $TaskNumber = 100

           #Create task filter for search

           $Filter = New-Object VMware.Vim.TaskFilterSpec

           $Filter.Time = New-Object VMware.Vim.TaskFilterSpecByTime

           $Filter.Time.beginTime = ((($Snapshot.Created).AddSeconds(-5)).ToUniversalTime())

           $Filter.Time.timeType = "startedTime"

           $Filter.Time.EndTime = ((($Snapshot.Created).AddSeconds(5)).ToUniversalTime())

           $Filter.State = "success"

           $Filter.Entity = New-Object VMware.Vim.TaskFilterSpecByEntity

           $Filter.Entity.recursion = "self"

           $Filter.Entity.entity = (Get-Vm -Name $Snapshot.VM.Name).Extensiondata.MoRef

           $TaskCollector = Get-View ($TaskMgr.CreateCollectorForTasks($Filter))

           $TaskCollector.RewindCollector | Out-Null

           $Tasks = $TaskCollector.ReadNextTasks($TaskNumber)

               #Get only the task for the snapshot in question and out put the username of the snapshot creator

               FOREACH ($Task in $Tasks)

                   {

                   $GuestName = $Snapshot.VM

                   $Task = $Task | where {$_.DescriptionId -eq "VirtualMachine.createSnapshot" -and $_.State -eq "success" -and $_.EntityName -eq $GuestName}                         

                   IF ($Task -ne $null)

                       {

                       $SnapUser = $Task

                       }

                   $TaskCollector.ReadNextTasks($TaskNumber)

                   }

               #Create a custom object for reporting

               $objReport = New-Object System.Object

               $objReport | Add-Member -Type NoteProperty -Name "Name" -Value $Snapshot.Name

               $objReport | Add-Member -Type NoteProperty -Name "Description" -Value $Snapshot.Description                

               $objReport | Add-Member -Type NoteProperty -Name "Created By" -Value $SnapUser.Reason.Username

               $objReport | Add-Member -Type NoteProperty -Name "Attached To" -Value $Snapshot.VM

               $objReport | Add-Member -Type NoteProperty -Name "Created On" -Value $Snapshot.Created

               $Report += $objReport

           #There is a default limit of 32 collector objects, destroying collector after use

           $TaskCollector.DestroyCollector()

           }

Tags: VMware

Similar Questions

  • How to use the script "click menu item" command on a menu item for an application that runs under another user?

    Hey everyone, quick question...

    I am trying to run this script:

    say application "System events".

    say process of "iTunes."

    click on menu item "Start Station" from the menu 'Song' to menu bar item 'Song' in the menu bar 1

    end say

    end say



    The idea behind this is to start a song selected currently playing station. I know, it's not hard to do it manually, but I want to be able to do it without having to call the iTunes app to the front. Now, this script works for my own iTunes app, but I have a second instance of iTunes connecting the second user on my computer at home (User2), with its own separate library and account and all. script I have works fine for an instance of iTunes under my user account, but I can't figure out how to specify which instance of iTunes, I'd like the script to work on.




    I want to emphasize as an FYI that i use.


    the shell script "connection f User2 /Applications/iTunes.app/Contents/MacOS/iTunes > & - 2 > & - &" with administrator privileges

    -to open my second instance of iTunes as User2



    is there a way to change the "process"iTunes"to say" something like 'process 'unix ID' say' and have the ID for each respective instance of iTunes unix?


    Let me know if I do not make sense... Thanks in advance to anyone who can help






    You can target a process of application using various properties of system events, for example:

    tell application "System Events"
      tell first item of (get application processes whose unix id is 15174) -- or whatever id
        activate --> needed when using GUI scripting
        get properties
      end tell
    end tell
    
  • Name of access to case / battery inside the case using VI scripts

    Hello everyone. I have a script that finds all instances of a specific under vi. All instances of this subroutine VI will be contained in a box structure. Using VI scripts, I want to be able to cross back and determine the name of the case that the sub vi is in. Is attached an image of the code that I currently have, however he mistakes in the part where I cast the reference to a case structure. Anyone know what I am doing wrong? Thank you.


  • How can I put a digital indicator in a box structure using VI scripts

    I am using VI scripts and I try to add a digital indicator within a box structure.  I'm able to add the structure of the case and the digital display fine, but as soon as I determine the structure of the case as the 'owner' of the digital (rather than the pattern-block being owner) I get error 1060.  Is there a way to get around this?

    Note: I am doing this is because this particular (indicator in a case structure) provision will prevent a VI to be inline when it is built.  This model will provide no functionality itself, it prevents only inlining.  It is added to a larger VI which is used to initialize objects in a simulation, and there are many of them in the total simulation.  If they are inlined, it takes a long time to generate the C code and a performance on this VI is not a problem because it is run only once at the beginning of the simulation.  The rest of the screw must be inline for performance reasons.  Therefore, I am open to other options to avoid a screw of Inline if 'the indicator in a structure of the case' can be done via the script.

    If this is not clear, please let me know and I can clarify.  Thank you.

    Sorry for the mess, it works for me.

    Don't mind the empty cluster constants.

  • How to detect programmatically something dirty in labview vi using labview scripts

    Hi people,

    I'm trying to write a code that passes by a few screws and check if they have a dirty point using labview scripting but have a moment difficult trying to find a way to do this. is it possible that I can do this? any help is greatly appreciated!

    S

    Have you tried this VI property?

    http://zone.NI.com/reference/en-XX/help/371361K-01/lvprop/vi_modvi_modificat_bitset/

  • We will use a script that allows users to connect only once.

    We will use a script that allows users to connect only once. 
    However some users need a second possibility of connection.
    How is - this can be handled in a script?

    The users in question are members of the same group secuity.

    Where the use of Windows server 2003 with xp clients.

    Hello

    Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in Windows 7 IT Pro Technet Forums network.

    http://social.technet.Microsoft.com/forums/en/category/WindowsServer/

    I hope this helps.

  • How to use the Script TCL EEM in router?

    Dear all,

    I have a TCl Script (it's 1 to test and understand).

    ********************************************** TEST.tcl *******************************************

    : model cisco::eem:event_register_syslog "Interface FastEthernet0/0, changed State to.

    import namespace: cisco::eem: *.
    import namespace: cisco::lib: *.

    Table game arr_einfo [event_reqinfo]

    action_script enable status

    If {[catch result {cli_exec $cli_fd (fd) 'enable'}]} {error $result $errorInfo}

    If {[catch result {cli_exec $cli_fd (fd) 'int fa0/1'}]} {error $result $errorInfo}

    If {[catch result {cli_exec $cli_fd (fd) 'shut'}]} {error $result $errorInfo}

    action_syslog msg "New Port is now"

    If {[catch result {cli_close $cli_fd (fd) $cli_fd (tty_id)}]} {error $result $errorInfo}

    ********************************************** TEST.tcl *******************************************

    Can someone tell me how to use this script in router that will be used every time my interface fa0/0 he'll fa0/1 in stop mode?

    Can you give me the steps to follow in the router?

    Wharton are the sine qua non for the use of this?

    Concerning

    Concerning

    Virtually any command, Yes.  You can't do "?" as you can from an interactive session, but you can run all the commands EXEC and config otherwise.

  • Using java script with QML, save a text in a variable of java script and showing in a label

    I'm trying to find a way to take a text entered by the user into a text field and display it in a label using java script. The trickiest part is I want to be seen in the label after restarting the application.
    Any idea?
    Should I use a JS file with functions. If so, what are best practices?

    Thanks in advance!

    This example uses a little bit of C++, I'm not sure if this can be done with purely JS

    in your text box or label apply onTextChanged you probably want to have a Setup button to activate & deactivate the area of text, or if they delete it, the text of the label would be erased

    . QML

    TextArea {
        id: myTextArea
        onTextChanged: {
            myTextArea.text = myLabel.text;
            //you could also apply ^ to a button's onClicked function etc
            App.saveValueFor("mySavedText" myTextArea.text);
        }
    }
    Label {
        id: myLabel
        text: App.getValueFor("mySavedText", "");
    }
    

    App.saveValueFor (); QSettings uses will have to be reset in your ApplicationUI.cpp & .h

    .cpp

    App is obtained by setting a context property

    qml->setContextProperty("App", this);
    
    QString App::getValueFor(const QString &objectName, const QString &defaultValue)
    {
        QSettings settings;
    
        // If no value has been saved, return the default value.
        if (settings.value(objectName).isNull()) {
            return defaultValue;
        }
    
        // Otherwise, return the value stored in the settings object.
        return settings.value(objectName).toString();
    }
    
    void App::saveValueFor(const QString &objectName, const QString &inputValue)
    {
        // A new value is saved to the application settings object.
        QSettings settings;
        settings.setValue(objectName, QVariant(inputValue));
    
    }
    

    all

    public:
    
        Q_INVOKABLE
        QString getValueFor(const QString &objectName, const QString &defaultValue);
    
        Q_INVOKABLE
        void saveValueFor(const QString &objectName, const QString &inputValue);
    

    You'll also need to slect the permission of files shared in the descriptor for QSettings bar to work

  • Cannot access a Web site using Java Script

    Cannot access a Web site using Java Script. I'm not sure what it blocks I use Win 7, Avast free, AntimalwareBytes.
    I get a pop up window with
    Name: mcs
    Location: http://myspeedtest02.windstream.net  
    say "application blocked by security settings, blocking the untrusted application.
    I don't know what it blocks, but suspect it is related to the security of Windows.
    I think that the Java Applet is blocked, but I would like to run this test of speed from my ISP.  I tried to access the website of Google Chrome and IE, with the same result. Nobody knows what this block and how to unlock it?

    This is actually not JavaScript, it's Java.  Despite the name, they are really very very different.

    Java itself can be dangerous, especially if it is not a trusted application.  It is my sincere recommendation that you do not continue.

    If you want anyway, you can go into your control panel, open the Java settings and set it to allow untrusted applications.

  • How to use between operator in Disqualification without using the script processor?

    Hello Experts,

    How to use between operator in Disqualification? for example phonenumberLength between 7 and 10. I don't want to use the script processor? Also how to reproduce the SWITCH statement Disqualification CASE?

    Thank you

    Konate

    1 Add a processor 'check the length.

    2. connect the transformer and open the configuration dialog box

    3. in the tab 'Attributes' select your attribute of telephone number as the "field Check.

    4. in the tab "Options", enter "7-15"in the option 'number of valid characters.

    5. run the process.

    a. accounts with [included] a character length 7-15 phone numbers out of the release of "valid".

    b. records with a length of character <7 or="">15 phone numbers out of the release of "Invalid character count.

    Note: the processor also adds a 'LengthValid' flag attribute which you may also branch on [with the values "Y" and "NC" for both scenarios above]. See Library of processor of the online help for more information.

    Thank you

    Nick

  • get the id of the component using Java Script

    I have three text fields that I am trying to reset it using Java Script in the Joint Strike Fighter. When, in short, all the text fields three triggered event calls the method below and not reset the other two fields to the point.

    I need to know what text field is under discussion, so I can reset the other two.

    The question that I have does not have the correct id name using evt.getSource ();. I get a big long text for txtField, that looks like: AdfRichInputText [oracle.adf.RichInputText] id = it2

    I'm trying to get just "it2", how do I do this?

    < af:resource type = "javascript" >

    function resetFields (evt) {}

    var txtField = evt.getSource ();

    Alert (txtField);

    If (txtField == 'it2') {}

    var var1 = AdfPage.PAGE.findComponentByAbsoluteId ('it1');

    var var3 = AdfPage.PAGE.findComponentByAbsoluteId ('it3');

    var1. SetValue("");

    var3. SetValue("");

    }

    }

    < / af:resource >

    Thank you very much.

    It worked:

    var txtField = evt.getSource ();

    ID var = txtField.getProperty ("id");     -Returns the name of id for the event source.

  • How to enable HTML access in the office pool by using PowerShell script?

    Hello

    I use to create pools of auto related clones using a script PowerShell/PowerCLI Office. The script provides all the parameters required for the Add-AutomaticLinkedClonePool cmdlet and there is a lot of it! Creating pools in this way allows me to save about 100 clicks per pool.

    Now I want to enable access HTML for each pool, but I can't seem to find the name of the parameter.

    I checked the properties of the object returned by Get-pool-pool_id w7mw620 and compared to other similar properties office pool where access HTML has been disabled. I coulnd't not see any differences in the property values, which seem to make a significant difference for the setting "enable access HTML '.

    There was a property named "calculatedValues", which was true for one and False for the other office pool. I don't know what is the meaning of this property. Help the cmdlet Add-AutomaticLinkedClonePool or AutomaticLinkedClone-set to list this property.

    So... How can I set the property to allow access HTML from a PowerCLI script?

    Hello, in response to my own question again...

    On the basis of the above VBScript example, I invented this PowerShell code snippet that does the work of activation / deactivation of HTML access to one or more funds pools, by adding or removing 'BLAST' to the allowed protocols. It's a beast of a code, and I think that this code can still be optimized/shortcut. It works for me. It allows the use of wildcards to select a number of pools of office to toggle HTML access to.

    To use it, just customize two variables constant to match your environment:

    $dn must maintain the name of the root of your ADAM database. I think that this name is the default, but I don't know about you.

    $domain must maintain the computer name or address IP and/or port number where the ADAM database is stored. You must also have sufficient permissions to connect if it is something else then "localhost".

    function Set-BCPoolHtmlAccess ([string]$Pool_id, [boolean]$HtmlAccess) {
    <#
        .SYNOPSIS
            enables or disables HTML Access to the given VMware View desktop pool
        .DESCRIPTION
            This function enable or disable HTML Access to a desktop pool, by modifying
            the "pae-ServerProtocolLevel" property of the associated object in the ADAM
            database via LDAP. This property is a multi-valued attribute contains a array
            of string, which designates
            by which protocol desktops can be accessed. It valid values are "PCOIP",
            "RDP" and "BLAST". Controlling the existance of the string "BLAST" determines
            if the pool is accessible through HTML Access. The parameter Pool_id determines
            which object is modified.
        .EXAMPLE
            Set-BCPoolHtmlAccess "W7ST620" $True
        .PARAMETER Pool_id
            the pool_id of the desktop pool of which to enable or disable HTML access. Wildcards are allowed!
        .PARAMETER HtmlAccess
            Boolean value to set the HTML Access to.
        .OUTPUT
            None
        .NOTES
            Written by Paul Wiegmans on 31-8-2014
            "pae-ServerProtocolLevel" is a multivalued attribute, which is a little difficult to
            write correctly to the object.
            http://www.selfadsi.org/write.htm
                    Google "powershell ldap multi value property"
            http://jdhitsolutions.com/blog/2011/12/updating-multi-valued-active-directory-properties-part-1/
    #>
        $dn = "DC=vdi,DC=vmware,DC=int"   # root OU of VMware View ADAM database (CUSTOMIZE ME)
        $domain = "LDAP://localhost:389/$dn"  # connect to the ADAM database (CUSTOMIZE ME) 
    
        $root = New-Object System.DirectoryServices.DirectoryEntry $domain
        $query = New-Object System.DirectoryServices.DirectorySearcher
        $query.searchroot = $root
        $query.filter = "(&(objectCategory=pae-DesktopApplication)(cn=$pool_id))"
        $pools = @($query.findall())
        $propname = "pae-ServerProtocolLevel"
    
        foreach ($pool in $pools) {    
    
            $poolobj = [ADSI]$pool.GetDirectoryEntry()
            $protocols = $poolobj.$propname
            $desiredprotocols = @()
            foreach ($protocol in $protocols) {
                if ($protocol -ne "BLAST") {
                    $desiredprotocols += $protocol  # save a list of all existing protocols
                }
            }  
    
            if ($HtmlAccess) {
                $desiredprotocols += "BLAST"
            }
            write-verbose ("Desktop pool " + $poolobj.name + " gets protocols: "+$desiredprotocols)
            $poolobj.$propname = $desiredprotocols
            #$poolobj.$propname = @("PCOIP","RDP","BLAST")  # to reset to normal values
            $poolobj.CommitChanges()
        }
    }
    
    $pool_id = "W7S*"                  # pool_id of pool to set protocols of
    Set-BCPoolHtmlAccess $pool_id $false
    Set-BCPoolHtmlAccess $pool_id $true
    

    Have fun

    Post edited by: Sikkepitje

  • How to change type of police using InDesign scripting (Javascript)?

    Hello

    I need to change the font type of a document, InDesign using InDesign script (javascript). I found a few online references in the InDesign scripting guide and running extract next, gives me errors.

    Delete existing preferences

    app.changeTextPreferences = NothingEnum.nothing;

    app.findTextPreferences = NothingEnum.nothing;

    app.findChangeTextOptions.caseSensitive = false;

    app.changeTextPreferences.appliedFont = app.fonts.item ("DEVANAGARI MT");

    App.Documents.Item (0) .changeText ();

    Download the msg of InDesign server.

    Error code: 1

    Error description: changeText

    The indesign file that is used to change the font is certainly not corrupt, cause the following script to export the file in .png works very well. Any help appreciated.

    app.pngExportPreferences.exportResolution = 100.0;

    App.Documents.Item (0) .exportFile (ExportFormat.PNG_FORMAT, PreviewDocument don't);

    Hello

    Try this 1-liner:

    app.documents.item(0).stories.everyItem().appliedFont = app.fonts.item("DEVANAGARI MT");
    

    Guess above specified police is available. Some disorders may begin with the name of the font, cause not always WYSIWYG.

    To be sure how to refer to a specific font by its name - a console text and notice of runing ESTK select this option:

    app.selection[0].appliedFont.name
    

    Jarek

  • Conversion of underlined text of the word by using a script

    Hello

    When you place a Word document, I want to use a script to convert the text underlined italic character Style (which I have already created). Which should read the line of app.findGrepPreferences to find the underlined text?

    Thank you.

    It's as simple as that:

    app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
    app.findTextPreferences.underline = true;
    app.changeTextPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item("italic");
    app.changeTextPreferences.underline = false;
    app.activeDocument.changeText();
    

    unless she needs deep integration into your current script.

    Related issues of script can better ask in the forum script: InDesign Scripting

  • How to use the script to display the number of columns contain no data

    I have a requirement. There is a source that is the excel, the excel file file, we need to load data into the staging table. There are 5 columns mandatory ones must not be null. We used "No. Data Check" for this. The logic is so mentioned previously mentioned 5 columns don't contain any record that the record will be moved to without data. So far, it is fine. Now the requirement is to show what column or columns contain no data. We used a script to do this like:

    RES =' '

    RES = input1 [0] + ": failed because values null in required columns;"

    INPUT1 [1] = res;

    Output 1 = res;

    But it shows message "down because of nulls in the required columns", which is a generic message. We must show what column or columns does not contain the value "failed because of null values in a column required columnA, columnB or columnC. Can someone help me in this regard. Any kind of help is appreciated.

    You can use the variable inputname1, which keeps an array of names of the entry for the script processor attribute. For example:

    var result = "";

    var first = true;

    for (i = 1; i< input1.length;="" i++)="">

    If (input1 [i] == null | input1 [i] == ' ') {}

    If {(first)

    Firstly = false;

    } else {}

    result += "";

    }

    lead inputname1 += [i];

    }

    }

    If (result.length > 0) {}

    result = "failed due to null values in the following mandatory columns:"+ result; "

    }

    Output 1 = result;

    Kind regards

    Nick

Maybe you are looking for