Problem combining Get - VM and Get-View

I worked on a script for a while, and very close if he's working as I want.  The script below is what I have so far and works as I want.

$(foreach ($cluster get-cluster) {get - view - viewtype VirtualMachine - SearchRoot $cluster.id | select @{N = 'The virtual computer name';}) E={$_. Name}}, @{N = "PowerState"; E={$_. Summary.Runtime.PowerState}}, @{N = "guest operating system"; E={$_. Config.GuestFullName}}, @{N = 'Cluster'; E = {$cluster. Name}}, @{N = 'Notes'; E={$_. Summary.Config.Annotation}}})

However, I can't seem to shoot our custom annotations by using Get - view but can't Get - VM.  The script below works.

Get - VM | Select Name, @{N = "Org1.Environment"; E = {(Get-Annotation-entité $_-CustomAttribute "Org1.Environment").} Value}}

How to combine the two?  Any help would be greatly appreciated.

Hello, Grimdari-

You are pretty close to.  A couple of ways you could do this, the first using the code of Get-Annotation you did already:

foreach ($cluster in Get-Cluster) {    Get-View -ViewType VirtualMachine -SearchRoot $cluster.id | Select @{n="VM name"; e={$_.Name}},        @{n="PowerState"; e={$_.Summary.Runtime.PowerState}},        @{n="Guest OS"; e={$_.Config.GuestFullName}},        @{n="Cluster"; e={$cluster.name}},        @{n="Notes"; e={$_.Summary.Config.Annotation}},        ## using the Get-VIObjectByVIView cmdlet; slower        @{n="Org1.Environment"; e={(Get-Annotation -Entity (Get-VIObjectByVIView $_) -CustomAttribute "Org1.Environment").Value}}} ## end foreach

And the second, stick with the info you've already recovered in the call to Get-View :

## selected properties to retrieve in Get-View call$arrViewPropertiesToGet = "Name","Summary.Runtime.PowerState","Config.GuestFullName","Summary.Config.Annotation","CustomValue","AvailableField"foreach ($cluster in Get-Cluster) {    Get-View -ViewType VirtualMachine -Property $arrViewPropertiesToGet -SearchRoot $cluster.id | Select @{n="VM name"; e={$_.Name}},        @{n="PowerState"; e={$_.Summary.Runtime.PowerState}},        @{n="Guest OS"; e={$_.Config.GuestFullName}},        @{n="Cluster"; e={$cluster.name}},        @{n="Notes"; e={$_.Summary.Config.Annotation}},        ## just using the data already retrieved; far faster        @{n="Org1.Environment"; e={$viewThisVM = $_; ($viewThisVM.CustomValue | ?{$_.Key -eq ($viewThisVM.AvailableField | ?{$_.Name -eq "Org1.Environment"}).Key}).Value}}} ## end foreach

The second way is much faster, though it might be a little less obvious how she came up with the results.  He becomes the value of CustomValue where CustomValue key corresponds to the key AvailableField for the AvailableField with the name of the attribute you want.  Anyway, how those who do for you?

Tags: VMware

Similar Questions

  • Problem combining accounts ePrint and snapfish

    I have problems connecting ePrint, because the connection gives me a popup saying: "" it seems that you have a Snapfish account and an account ePrintCenter, which use the same address. ". We will combine these accounts to make easier access to both services. »

    I put my password of Snapfish, but it is declared "invalid". I have reset my password to Snapfish on a new, but it still does not accept the password. I tried clicking on "Forgot password?" in the context menu, and depending on the password reset procedure here, but still the popup does not accept my password and allow me to go further, unless I combined accounts.

    Is there a way I can go beyond that?

    Thank you

    Matt

    I sent Snapfish support ([email protected]) and asked them to remove my account. I can now connect to the ePrint Center ok.

    Just in case this helps everyone who suffers from the same problem.

    Concerning

    Matt

  • Windows Picture and Fax Viewer is blocked with force close after seeing some pictures on my computer (os win 7))

    Hello

    I am facing problems with Windows Picture and Fax Viewer, it crashes after viewing the rare photos (ex: 6-10 + photos).

    My OS is win 7 home basic SP-1.

    This product even after reinstalling the OS, can u please help me?

    Thank you
    Sharath.

    Hi Sharath Reddy,

    Thank you to contact the community Microsoft and we will be happy to help you with your concern.

    According to the description, it looks that you are having problems with crashes Windows Picture and Fax Viewer.

    This problem could be due to outdated video card drivers: -.

    1. When was the last time you were able to use the photo viewer?
    2. have you made changes on the computer? For example:-hardware or software
    3. what type of video card do you have on the computer?

    Method 1:
    Try also to clear temporary folders by going to
    a:  Click on Start and type in run and press enter
    b: In the Run window, type % temp % and press ENTER. Opens Windows Temp
    c: Delete the contents of the Temp folder

    Method 2:
    This issue could be with the old driver files, that's why I suggest you to update the latest drivers on your computer.

    Step 1 : to get the latest drivers for the computer.

    Click on the link below for more information on the update of drivers.
    http://windowshelp.Microsoft.com/Windows/en-us/help/b3c6477e-1111-4B9F-A52A-fffdc51e9c901033.mspx

    Step 2: Now you need to reduce the hardware acceleration on your computer and look for the number, to determine this, click on the view tab and then, under DirectX features, check to see whether DirectDraw, Direct3D, and AGP Texture acceleration appear as disabled. If this is not the case, try to reduce hardware acceleration.

    a:  Open Screen Resolution by clicking on the Start button, Control Panel, and then, under appearance and personalization, click on the resolution of the screen.
    b:  Click on avancΘs.
    c: Click the Troubleshooting tab, and then click on change settings. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.
    d: Move the hardware acceleration to min.

    Please let us know if the steps above resolved the problem.

    For more information you can visit the link provided below.
    http://Windows.Microsoft.com/en-us/Windows7/diagnosing-basic-problems-with-DirectX

    Answer to us if you are having problems with Microsoft Picture and Fax Viewer or any other issue of Windows, and I'd be happy to help you.

    Good day!

    Hope this information helps.

  • Double click on the photo (my photo) causes PC freeze with message "not responding" (scheduled for the windows fax and picture viewer)

    WINDOWS XP

    "This program is not responding...". »

    I then have to click on the right upper window X two times to close the window. When it closes Finally, everything on the desktop disappears for about 3 seconds then reappears as if the PC restarted, but it does not actually restart.

    My images, the other day, all open without this feeze/final issue. I don't have these problems when you use Windows XP Paint, Jasc Paint Shop, or Quicktime to open images, once set by default... Just does not work with Windows Picture and Fax Viewer more and all my photos are already defined (default) to open with Windows Picture and Fax Viewer - clicking Properties confirms this.

    Also, if I right click on the individual image to 'open with' and manually choose 'open with' Windows Picture and Fax Viewer, it will then open and I can scroll all the following pictures an image in Windows Picture and Fax Viewer. "But I can't just click on an individual picture, otherwise, it will freeze just straight up.  Difficulty It Center Microsoft could not automatically repair because the shimgvw.dll file already exists.

    I used to always use Windows Picture and Fax Viewer with no such problems. I have not the slightest idea what happened... even though I was messing around with 1) Component Services > Security Com > permissions & launch Activate and Run permissions) 2 > Regedit > Edit > "Permissions" last week and changed "Registered Owner" in HKEY LOCAL MACHINE and some other stuff like that. Could permissions and changing names have caused this unexpected problem in Windows Picture and Fax Viewer? If so, the changes I made will not be changed back, then how can I fix a broken Windows Picture and Fax Viewer?  And if these changes, last week, have nothing to do with this "opening images in the image Windows and Fax Viewer problem,' so what?

    I did your suggestion before posting here. I saw the same solution as your addition, the interpreter, but it does not solve the problem because I already had the shimgvw.dll etc. in their proper place and my photos/images were not always open with Windows Picture and Fax Viewer the way I wanted them to open.

    Since I got my photos all open as I wanted (as before) this way to use Windows Picture and Fax viewer:

    Control Panel > Folder Options > File Types: I changed then each file/folder associated with 'images' to open with Windows Picture and Fax Viewer. I determined this by reading the details for each extension / the item highlighted. If the referenced details 'images', I then clicked on change and choose Windows Picture and Fax Viewer to open the extension.

    I went through everything everyone who was not obvious that they are. I made a change: BMP, GIF, EMF, JFIF, JPE, JPEG, etc... I changed at least 12 (more than I thought it was).

    Immediately after changing all of these types of files, I rebooted and Windows Picture and Fax Viewer was still working the way I wanted to (as before).

  • Can be combined in the same script Get - VM and Get - view?

    Hello

    I am trying to find a way to combine these two Get - VM and Get - view in the same script.

    Script # 1

    Get-Cluster Management | Get - VM | Select Name,@{Name="HardwareVersion; Expression = {$_.} ExtensionData.Config.Version}}

    Script # 2

    Get-Cluster Management | Get - vm | where {$_.powerstate - don't "PoweredOff"} | % {get-view $_.id} | Select Name, @{Name = "ToolsVersion"; {Expression = {$_.config.tools.toolsVersion}}, @{Name = "ToolStatus"; Expression = {$_.} Guest.ToolsVersionStatus}}

    I've always had problems try this out and now, I need to combine them into a single script in figure.

    If you can help me or point me in the right direction would be great.

    Thank you

    Mike

    Curiosity got the best of me so I came with this. You had more correct, but you need to make a custom object so that the properties you are looking for can all be used simultaneously.

    It does not use the pipeline and uses a foreach loop.

    ----------------------------------------------------------------------------------------------

    $vms = get-Cluster Management | Get - VM? {$_.powerstate - don't "PoweredOff"}

    {foreach ($vm to $vms)

    $VMID = get-View ($vm.id)

    New-object psobject-property @ {}

    VM = $vm

    HardwareVersion = $vm. ExtensionData.Config.Version

    ToolsVersion = $VMID.config.tools.toolsVersion

    ToolsStatus = $VMID. Guest.ToolsVersionStatus

    } | Select the virtual machine, ToolsVersion, HardwareVersion, ToolsStatus

    }

    ----------------------------------------------------------------------------------------------

    Or use this option if you like the pipeline with Foreach-Object approach.

    ----------------------------------------------------------------------------------------------

    Get-Cluster Management | Get - VM? {$_.powerstate - don't "PoweredOff"} | % {

    $VMID = get-View ($_.id)

    New-object psobject-property @ {}

    VM = $_

    HardwareVersion = $_. ExtensionData.Config.Version

    ToolsVersion = $VMID.config.tools.toolsVersion

    ToolsStatus = $VMID. Guest.ToolsVersionStatus

    } | Select the virtual machine, ToolsVersion, HardwareVersion, ToolsStatus

    }

    ----------------------------------------------------------------------------------------------

    Both methods are correct that I can see. I tried both and both work well. You can easily piple only out to Export-Csv at the end of the select line. I hope this helps.

    Andrew

    Post edited by: andrewsardinha
    condition of powerstate added to each block operator and foreach-object script to the last script block.

  • Just did my laptop, tried to do windows updates and get a message T "here has been a problem the site witt" and can not open the page I requested at this time.

    Just, I redid my laptop using my system recovery disks. I went to windows update and get this msg when I click on Express.com: the site has encountered a problem and cannot display the page you are trying to view.

    Original title: I redid all my laptop. I went to windows update and get a message that says: there was a problem witht the site and I wanted that the pag can not open the page I have requessted at this time.

    You must download and install Windows XP Service Pack 2 (if not already installed) followed in Windows XP Service Pack 3.  You will find two of them at http://www.microsoft.com/downloads - download the "Network Installation Package" for the two and ignore the part about them being only for the professionals - the parcel I recommend you download will install with or without network connection.

  • PowerCLI: Get - view filters and OR conditions

    Hi all

    I'm little a beginner when it comes to tools from command-line and scripting in general, but I was playing around with PowerCLI and Get - view in particular and I wanted to understand if there was a way to specify multiple conditions and a 'GOLD' between them make in filters.
    Something like...

    Notice-EEG - ViewType VirtualMachine-filter @{name = "ABC123" or snapshot! = "} # does not work

    I took a glance at the documentation and I was unable to find a solution, but maybe a more experienced writer can confirm this?
    Thank you!

    I'm afraid, this is not possible, that all expressions in the filter hash table must comply.

    So, indeed, all expressions are AND-ed together.

    You can make a combination of two Get - sight lines of course.

    But I admit that this solution is not elegant or optimal.

  • Using filters and Get - view to find virtual machines with a specific guest operating system.

    I have the following code snippet to find all virtual machines with the updated OS to ' Red Hat Enterprise Linux * "prompt. It does not work. If the filter is left out, I find myself with all virtual machines.

    The immediate question is the specs for the game ' Red Hat Enterprise Linux. " Originally from the "Performance Difference between GET - VM and GET-VIEW")

    http://www.batchworks.de/performance-difference-between-get-VM-and-get-view/ ).

    $ClusterFilter = Get-View -ViewType ClusterComputeResource -Property Name -Filter @{“Name” = $ClusterName } | select -ExpandProperty MoRef

    $VirtualMachines = Get-View -ViewType VirtualMachine -Property Config -SearchRoot $ClusterFilter


    The biggest problem for me is to understand for Get-View filter. I was capable of a bit of insight to gleen from the URL below, but I think what Miss me is the reference (Microsoft) for what is happening to the right of the equal sign. What is the correct terminology for this type of query expression / where the syntax is 'left' = 'straight' and keywords such as "-match" are not allowed.

    http://purple-screen.com/?Cat=3

    VMware vSphere 5.1

    http://Wannemacher.us/?p=259

    Regular expressions with Windows PowerShell

    Right in the filter expression is an RegEx expression, please allow for characters before and after the word Linux.

    And the name of the OS is Config.GuestFullName.

    I corrected the entries more early as well.

    $ClusterName = "^MyCluster$"$ClusterFilter = get-view -ViewType ClusterComputeResource -Property Name -Filter @{"Name" = $ClusterName } | select -ExpandProperty MoRefWrite-Host $ClusterFilter
    
    $VirtualMachinesNoFilter   = Get-View -ViewType VirtualMachine -Property Name,Config -SearchRoot $ClusterFilter $VirtualMachinesWithFilter = Get-View -ViewType VirtualMachine -Property Name,Config -SearchRoot $ClusterFilter -Filter @{"Config.GuestFullName"=".*Linux.*"}
    
  • Get-View and - filter

    I'm a (relatively) new convert to get - view the incredible increase in speed to run scripts PowerCLI through ESXi hosts hundreds / thousands of virtual machines.

    I've been struggling with how to do it with a list of the MV?  What I want to do, it's with a provided list of VMs get the hardware version and version of the tools.

    Normally, if you wanted a report of everything that you would do the following:

    Notice-EEG - viewtype VirtualMachine-property name, Config. Select Name, @{N = "HWVersion"; E={$_. Config.Version}},@{N="Tools '; E={$_. Config.Tools.ToolsVersion}} | FT-auto

    Now read on - filter is seems the way to go-, but it uses a hash table.  That is to say "Name" = "Foo".  It does not seem to manage 'Name' = $vmList where $vmList is a collection of multiple virtual machines.  I will not go into how if the variable is a unique virtual machine that Foo matches Foo and FooBar.

    What I have used is the following:

    $vmList = get-content c:\scripts\import\listofvms.txt

    Get - vm $vmList | Opinion-GET-property name, Config. Select Name, @{N = "HWVersion"; E={$_. Config.Version}},@{N="Tools '; E=$_. Config.Tools.ToolsVersion}} | FT-auto

    The only problem is that I feel like this is a workaround solution - it should all be achievable using get - view directly.  -If I wanted to use - filter, with a collection of virtual machines would how I did this?

    See you soon

    Robert

    Hi Robert,.

    If you use the cmdlet Get-view and search two VM called foo and bar, you will need to make a filter with a regular expression. You must use the vertical bar as a sign "or" in the regular expression. For example

    Notice-EEG - ViewType VirtualMachine-Property Name, filter-Config @{"Name"=' foo | "} bar'}

    You can use the .NET Join method string to construct the regular expression from the $vmList variable. Like this:

    $vmList = get-content c:\scripts\import\listofvms.txt
    Get-View -ViewType VirtualMachine -Property Name,Config -Filter @{"Name"="$([string]::Join('|',$vmList))"} | `
    Select-Object -Property Name,@{N="HWVersion";E={$_.Config.Version}},@{N="Tools";E={$_.Config.Tools.ToolsVersion}} | `
    Format-Table -AutoSize
    

    Best regards, Robert

    Post edited by: RvdNieuwendijk has added the explanation at the beginning of the post.

  • Problem has been detected and windows has been shutdown error STOP: 0x0000008E. Get the memory dump after you have installed the trial version of MS Project 2010.__space.

    Original title: problem has been detected and windows has been shut down. Get the memory dump after you have installed the trial version of MS Project 2010.__space.

    Computer Message: Check if you have enough disk space. If a driver is identified in the stop message, disable the driver or check with the manufacturer for driver updates. Try changing video cards.

    Check with your suppliers of material, updates the BIOS. Disable the BIOS memory options such as implementing caching or shading. If you need to use Safe Mode to remove or disable components, restart your computer, press F8 to start advance startup options, and then select Safe mode.

    Technical information: * STOP: 0x0000008E (0xC0000005, 0x8054556C, 0xADB78A98, 0x00000000)

    Beginning physical memory dump

    Total physical memory dump. Contact technical support for further assistance group.

    Hi fernandomventura,

    Step 1: Disconnect all external devices (printers, scanner, USB (universal serial bus) readers, etc...) Except the keyboard and mouse and then start.

    If this solves the problem, then add back devices at a time until you discover the piece of hardware causing the issue.  Then get any drivers\software update for the device.

    Step 2: Follow the steps mentioned in the articles below which deals with a similar question

     

    General troubleshooting for an error message that you receive randomly in Windows XP: "Stop 0x0000008E"-restore the system to achieve ".

    http://support.Microsoft.com/kb/945658/

    You receive a random "0x0000008E" error message on a blue screen in Windows XP

    http://support.Microsoft.com/kb/827663

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • I get an error code 10. DT High Definition Audio CODEC driver problem. Have uninstalled and re installed, still no progress. Any advice? I have

    I bought a new laptop, Dell Vostro 3550 and found pirated software. I installed Windows 7 Pro (64 bit).

    There is no sound at all. Get a code 10 message, IDT High Definition Audio CODEC has a driver problem. I uninstalled and re installed the driver without result.
    If anyone can help?

    Hello Eugene,

    When you installed Windows 7 Pro, did you do a reformat and clean install, or have you just loaded Win 7? Part of the problem may be a residual of pirated software. I recommend a reformat and clean install if you can do it now.

    In the contrary case, the thing to look at is if there is a driver conflict between what driver is there now compared to what was there. Go to control panel | Device Manager and watch the video, sound, and game controllers section. What drivers are here for audio? And which audio driver your speakers are pointed to? The active audio driver suitable for your speakers.

    If you could answer my questions, I might be able to help you further.

    Kind regards

    BearPup

  • Can any body help to get a script that can generate the sequence (length 3) with a combination of numbers and characters example: T11... TA1... TZ9... then on

    Can any body help to get a script that can generate the sequence (length 3) with a combination of numbers and characters example: T11... TA1... TZ9... then on

    With the help of the clause type

    Select sqnc

    from (select sqnc

    from (select 'T00"sqnc, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ordr

    of the double

    )

    model

    size of (0 I)

    measures (sqnc, ordr, length (ordr) len)

    rules iterate (1300) until (instr(sqnc[iteration_number],'~')! = 0)

    (sqnc [iteration_number] = case when sqnc [cv (i) - 1] is null

    then sqnc [0]

    of another substr (sqnc [iteration_number - 1], 1, 1) |

    -case when substr (sqnc [iteration_number - 1], 2, 1)<=>

    so when business substr (sqnc [iteration_number - 1], 3, 1)<>

    then substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 2, 1)), 1)

    of another nvl (substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 2, 1)) + 1.1),'~ ')

    end

    end |

    -case when substr (sqnc [iteration_number - 1], 3, 1)<>

    then substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 3, 1)) + 1.1)

    else ' 0'

    end

    end

    )

    )

    where instr(sqnc,'~') = 0

    Concerning

    Etbin

  • Update for the application manager has failed. Impossible to reinstall. Cannot use my apps. Get the 43 error message when I try to re - install. Is it possible to fix this problem without a wipe and load?

    Update for the application manager has failed. Impossible to reinstall. Cannot use my apps. Get the 43 error message when I try to re - install. Is it possible to fix this problem without a wipe and load?

    Error 43 https://forums.adobe.com/thread/2070909

  • If I started a project in first Cs5 and want to finish it in first Pro CC it causes problems exporting my sequence and get into the new software?

    If I started a project in first Cs5 and want to finish it in first Pro CC it causes problems exporting my sequence and get into the new software?

    Better is to import the cs5 project in the new project of CC.

    And Yes this could have problems, he could not.

    I would have ended up in CS5. Export to the lossless format and encode with SOUL CC until the final destination.

  • I just had a software problem with my Mac. and had to reload everything with Apple. Only one problem. Lightroom is gone. Apple said that the address has changed. How can I get my pictures back? Can anyone help?

    Hi all

    I just had a software problem with my mac and had to reinstall everything using Apple. One problem, lost lightroom 5. Apple said that the code of the address has changed. How to recover my photos or have I lost?

    At soon Pete J

    Hi Pete,.

    You can install Lightroom via this link:

    Download Photoshop Lightroom

    However, to get the rear changes you have previously done in Lightroom, you need to get the backup of your previous Lightroom Catalog.

    Store you the backup of your Lightroom catalog before recharging your Mac OS?

    Kind regards

    Claes

Maybe you are looking for

  • ScreenSharing stops working after restart server 10.8

    We run a mini Mac running OS X 10.8.5 with 2.2.2 installed server. The server share some readers with us and, in addition, services such as DHCP, DNS, FTP, OD. A few days ago an external drive stops the job server so we had to restart the hard way. A

  • Updates when?

    I have all these tablets and phones that are now almost two years. I have three 7 Nexus and Nexus two, 4. All of them perform Lollipop 5.0.1 and 5.0.2. Yes, I know that these are the flagship of Google line. But, come on, this brand new HP Slate 21 P

  • Create an executable version for eurotherm driver tools

    Hello I would like to know if anyone has or can create an executable version from the instrument to the eurotherm 3216 vi driver monitoring temperature control. I downloaded the file from the Web site or http://sine.ni.com/apps/utf8/niid_web_display.

  • HP Officejet Pro 8000 printer - A809a. Drivers not installed

    I have a wonderful printer HP Officejet Pro 8000 - A809a used exclusively as a network printer and works PERFECTLY. Yet, I have errors reported about drivers not installed in device (Windows 7, 64 bit Ultimate) Manager. These are: 1] adapter Multifun

  • Creation of the disk recovery Partition recovery disks or HARD.

    I hope that I get good advice from experts today. Is it possible to create a custom (mine) HARD drive recovery partition? Is it possible to create discs of recovery with all the updates and the installed program? Is it possible to update the recovery