Get-vmhost does not reflect the number of correct hosts on a few scenarios

Hello members of the community.

When I try to use the cmdlet get-vmhost against a cluster that has one or no hosts in there, I don't get the number of correct hosts. Here are some lines for this information.

foreach ($objDataCenter to $objColDataCenters)
{
$objColClusters = get-Cluster-location $objDataCenter

foreach ($objcluster to $objColClusters)
{
$Details = $Null
$objClusterBaseRP = $objHosts = $objDataStores = $objVMs = $Null
$intNUmDatastores = $intNumHostCPUs = $intTotCPUMhz = $intTotUsageCPUMhz = 0
$intTotMemMB = $intTotUsageMemMB = 0
$CPUStat = $CPUStatMax = $MemoryStat = $MemoryStatMax = 0
$intTotMemGB = $intUsageGB = $intMemResGB = $intMemLmtGB = 0
$inttOTDiskCapacityMB = $intTotDiskFreeMB = $intTotDSCapacityGB = $intTotDSFreeGB = 0
$intTotVMMemGB = $intTotVMCPUMhz = $intNumVMCpus = $intTotVMMemMB = 0
$intTotVMProvisionedSpaceGB = $intTotVMUsedSpaceGB = 0

$objHosts = get-vmHost-location $objcluster

$objHosts.Count

}

}

code above produce white for clusters that has one host for all other groupings that has 2 or several hosts results are correct. I know that there is no point of having a single node cluster or not, but the result does not reflect his decent stats.

In the same way under lines also produce incorrect information to the cluster that has no HOST or a single HOST that is in maintenance mode and has no inside VMs

$objVMs = get-VM-location $objCluster

$objVMs | %{
$intNumVMCpus += $_. NumCpu
$intTotVMMemMB += $_. MemoryMB
$intTotVMProvisionedSpaceGB += $_. ProvisionedSpaceGB
$intTotVMUsedSpaceGB += $_.usedSpaceGB

}

When I print the values of all the variables above, it should report 0 instead I have the chance to see some numbers. Please note I have explicitly assign values $null to all objects and 0 in all other variables at the beginning of the loop for clusters.

Any help to solve this is greatly appreciated - thanks

Kind regards, Philippe

Hello, Ramkrish-

Welcome to the communities.

For the first part, the number of hosts in a cluster with zero (0) or one 1 host - there are a number of things happening there.

When the Get-VMHost call returns only one host, and you then try to access to the. Property of the count of $objHosts, you try to access this property on an object VMHost, not an array of length 1 with a VMHost inside.  And, since the VMHost object has no property '. " Count' you get a return of the 'white' or null.

And when Get-VMHost will return no host, and you are trying to access. Count on $objHosts, you effectively type '$null. "Count", since $objHosts - eq $null at that time.

Two ways to handle these cases would be to use the Measure-Object cmdlet or explicitly to a table, even if zero or one VMHosts are returned.  As:

## using Measure-Object$objHosts = Get-VMHost -Location $objcluster($objHosts | Measure-Object).Count    ## correctly returns 0 or 1 (or greater)...## or## forcing an array, even if 0 or 1 items returned$objHosts = @(Get-VMHost -Location $objcluster)$objHosts.Count        ## correctly returns 0 or 1 (or greater)...

Regarding the behavior you're seeing with the statement Foreach-Object with $objVMs, I suspect that the behavior of the Foreach-Object statement when you're running an empyt null him is at stake here.  In other words, while you can imagine "$arrEmptyArray | % {'Hello'}' to produce anything, happening actually by an interation of the loop (really - try - the).  So to avoid this, you can delete the unnecessary part that stores the output of Get - VM in the variable "$objVMs" and combine the lines to channel the output from Get - VM directly to the Foreach-Object statement, as:

Get-VM -Location $objCluster | %{    $intNumVMCpus += $_.NumCpu    $intTotVMMemMB += $_.MemoryMB    $intTotVMProvisionedSpaceGB += $_.ProvisionedSpaceGB    $intTotVMUsedSpaceGB += $_.usedSpaceGB}

By the way: while we're updating this code a little, another way that you could get these totals is again using the Measure-Object cmdlet, this time with the parameter - sum, as:

Get-VM -Location $objCluster | Measure-Object -Sum -Property NumCpu, MemoryMB, ProvisionedSpaceGB, usedSpaceGB

Much more compact and allows just of PowerShell do the work.  Although you then maintain the return of the object of measures, depending on the situation, it is quite practical.

How about that?

Tags: VMware

Similar Questions

  • Error #5001: The name of package 'mapTools' does not reflect the location of this file. Please change the pa

    OK, it's a simple question. I have a mapTools package defined in the MapManager.as ActionScript file, as shown in the attached code. The directory structure looks lke this:

    C:\
    -\engine
    -------Media
    -\Flash
    -\mapTools
    -MapManager.as
    --------------------------- MAP.fla

    If the MapManager.as and MAP.fla files are in the same directory. So I open MAP.fla and when I do TestMovie I get this error:

    "5001: the name of package 'mapTools' does not reflect the location of this file." Please change the name of the definition of the package inside this file, or move the file. C:\engine\media\Flash\mapTools\MapManager.as ".

    What is the cause of this error?



    If she is the document class, replace the fla in mapTools and remove mapTools the package name.

  • Zoom r16 output does not reflect the master Pro Logic output

    I have a Zoom R16 hooked to Logic Pro X on El captain.

    Everything seems to work fine, but the release of the Zoom R16 always gives the sound, the monitor of the line, not the output of Logic Pro X inputs. If the helmet and out of line always give the full release of all entries and not the combination of Logic Pro. On the master output indicators seem to give the right indication (that is, not if all the sliders are declining), but that does not reflect the sound on the output.

    Is this a settings problem, a problem with Logic Pro or a problem with the Zoom R16.

    Anyone who suffers it, or has a sollution?

    How exactly this is connected to your Mac?  I guess that via USB?

    You have the latest drivers for it?

    Have you checked the Audio 'MIDI settings' application (Applications > utilities) to check that it is correctly configured in the operating system?

    Have you checked its configuration in LPX?  Two place to check.  1 - logic Pro X menu > control surfaces > Preferences 2 - Logic Pro X menu > control surfaces > Setup

  • I have a problem loading Illustrator CS4 on a second computer (laptop). It does not recognize the number, saying: it is not valid. [was: ochre]

    I have a problem loading Illustrator CS4 on a second computer (laptop). It does not recognize the number, saying: it is not valid. Any suggestions on how to have the serial number recognized would be appreciated.

    Please see: error of incorrect serial number

    I hope this helps.

    Concerning

    Megha Rawat

  • frequently viewed topics report does not increase the number of new hit

    Hi experts,

    I have a project published on RH 9 server with webhelp pro. the frequent search term gives me reasonable counties, each time when the same search term, the number has increased. but the report of frequently viewed topics does not increase the number for the topic I clicked several times (whenever I have click on another topic and then return to click on the same subject). adobe support told me that I should close the window, then re - open the link and click again on the topic, but it still doesn't work. We finally know is that I have to delete all historical data in the cache and reopen the window, then click on the same subject, then the County will go through one.

    I wonder if this behavior is normal or not. If it is normal, how to use this report?

    Thank you

    Frances

    Hi Frances.

    I'm not an expert in browser, but it seems plausible. The browser cache is designed to avoid having to download content locally whenever a page is opened. Whenever a page is open to scrutiny is conducted to determine if the cache already contains elements of it. If it has, it uses this local version. With the local HR server as the version of the cache statistics are not being updated, because the page is not viewed from the server.

    It may be an idea to set your browser options to delete the history of every time that it is closed. Also, be aware that it is possible that different browsers may have slightly different options.

    Colum

  • Compiled CHM file does not reflect the name of the new project

    I have read many responses of experts to positions and have found them extremely useful is. However, I have not seen one that solves my problem.

    I have the HTML HR RH8 Version. I renamed a project through 1) file - rename project and 2) Single Source Layouts - main Layout - Properties - output folder and file name.

    Two problems are: 1) the name of the project file still reflects the old name of project and 2) the CHM file still reflects the old name of the project.

    Therefore, the output help the user displays a still the former name of the project in the title bar.

    Generated files like the RoboHelpHTML project file have been changed for the new name of the project, just like RENAME the PROJECTS using says it should. However, the CHM file does not reflect the new name of the project as it says it should.

    (1) can I change the name of the folder created when I compiled the help by exact name file?

    (2) can I change the FILE name in the window SELECT OUTPUT FOLDER AND FILE name?

    (3) I can / should I rename the names of table of contents and Index of the old project name for the new name of the project? (Help says changing the project name does not change these file names and he didn't.)

    None of these measures will correct the problem? I appreciate any help you can give.

    Welcome to our community

    Try file > project settings.

    And if that fails, try the pod project configuration, windows and change the caption of the window.

    See you soon... Rick

    Useful and practical links

    Wish to RoboHelp form/Bug report form

    Begin to learn RoboHelp HTML 7, 8 or 9 in the day!

    Adobe Certified RoboHelp HTML Training

    SorcerStone blog

    RoboHelp EBooks

  • try reinstalling AE CS6... ask the serial number which I then ask for cs5.5 which I did not... I have version 5, but does not accept the number. ?

    Try reinstalling AE CS6... ask the serial number which I then ask for cs5.5 which I did not... I have version 5, but does not accept the serial number.

    There should be a drop down menu where you can select the version that qualifies you for the upgrade activation (CS5 in your case).

  • After the 10.11.2, update Mac Mail does not show the number of unread emails badge.

    What can I do?

    A

    In the menu bar, you select

     ▹ System Preferences... ▹ Notifications application icon ▹ Mail ▹ Badge: on

    If the badge is still not displayed or displays the wrong count, see below.

    B

    Please stop Mail. Force quit if necessary.

    Back up all data before proceeding.

    If you use OS X 10.11 ("El Capitan") or version later, triple - click anywhere in the line below on this page to select:

    ~/Library/Mail/V3/MailData

    If you use an older version of Mac OS X, use this line:

    ~/Library/Mail/V2/MailData

    Copy the selected text in the Clipboard by pressing Control-C key combination. In the Finder, select

    Go ▹ go to folder

    in the menu bar. Paste in the box that opens by pressing Command + V, then press return.

    A file window opens. In it he must be files with names as follows:

    Index of the envelope

    ExternalUpdates.storedata

    Move these files to the desktop, leaving the window open. Other files in the folder can have names more long that begin as above. Move these files, if any, in the trash.

    Mail recovery. It should invite you to re - import your messages. You can get a warning that the index is corrupted and that Mail must quit smoking. Click OK. Generally speaking, the process takes a few minutes, but this can take hours if you have gigantic mailboxes. In this case, you will be able to speed things up temporarily by adding your file to the list of personal information protection in the Spotlight preferences pane. Remove it when Mail has finished importing.

    If the import operation stalls or fails with an error message, quit Mail, delete the two new index files (maintenance of the original that you moved to the desktop) and try again. According to several reports, the second attempt can succeed if one does not.

    Test. If Mail now works as expected, you can delete the files that you moved to the desktop. If not, post your results.

  • HP 1800 does not reflect the memory of 16 gb Micro SDHC

    I just add a card Lexar 16 GB Micro SDHC for my new HP 7 1800 but don't see any increase in available memory.

    Is that what the SDHC-compatible HP 7 1800?

    The instructions that I found do not mention using the Micro SD slot. Not even the way to remove the card.

    Anyone using a MicroSDHC card in their HP 7 1800?

    Thank you

    Jerry

    Ok. I found that the card works. Apparently the HP 7 1800 had only 5.56 GB g available plus 14.91 GB the card. I thought that the 1800 came with 32 GB GB 5.56 available does not seem like a lot.

    Also understand that the map is spring-loaded and pushing on it releases it.

    Jerry

  • writing cannot be porformed, because data channels number does not match the number of channels in the task

    Hello

    I'm writing analogues of the buffer to several channels using NOR-6723.

    For some reason any, whenever I go to the buffer double function (1-d) that contains buffers for all channels.

    I always find myself with exception indicating that the numbers of channels in the data are '1 '.

    I use c#:

    Task m_TaskHandle = new Task();
    
    string sChannelsList = "Dev2/ao21:23";
    
    m_TaskHandle.AOChannels.CreateVoltageChannel(
    
    sChannelsList,
    
    "", 0, 5, AOVoltageUnits.Volts );
    
    int iNumberOfSamples = 4;
    
    double dSamplingFrequency = 1000;
    
    m_TaskHandle.Timing.ConfigureSampleClock("",
    
    dSamplingFrequency,
    
    SampleClockActiveEdge.Rising,
    
    SampleQuantityMode.ContinuousSamples,
    
    iNumberOfSamples /* Only relevant if mode is FiniteSamples */);
    
    // Data code is heredouble[] adSampleBuffer;// array values removed from this code snippet (here i have function that generates data)// array size is: num_of_samples * total_channels (in this case 4 * 3)
    
    AnalogSingleChannelWriter ChanWriter = new AnalogSingleChannelWriter(m_TaskHandle.Stream);
    
    ChanWriter.WriteMultiSample(false, adSampleBuffer);
    
    m_TaskHandle.Start();
    

    Not sure I'm I missing, how the MSTDIO determines the "number of data channels", I receive as an exception, it is always equal to 1.

    would appricate to help.

    Thank you.

    Hi idanbis,

    As the snippet you posted, you can create more than one channel using the ao21:23 range. That said, you should use AnalogMultiChannelWriter to configure your write instead of AnalogSingleChannelWriter operation.

    To write using AnalogMultiChannelWriter::WriteMultiSample (boolean, double, you must know the data you want to write must be stored in a 2D array.) Each element in the first dimension of the array corresponds to a channel in the task, while each item in the second dimension, to a sample of write on its channel. For example, that:

    Double [,] data = new double [numChannels, numSamplesPerChannel];

    Then:

    data [0, 0... numSamplesPerChannel]; It is the set of all samples in the first string (ao21 in your code).

    I hope that was helpful. Let me know if I left any doubt remaining.

    Best regards

    Anzurio

  • Last updated to IE8 has crippled my internet access. IE8 is now "expires" and does not display the number of pages.

    Internet exployer time out and don't load pages with java, flash, or redirects after the last update, "Security update for Internet Exployer 8 ' Pages will be 'time out' with the page to"diagnose connection problems ". (a constant joke that IE8 will expire)
    I tried to uninstall the update, but still need settings that are the cause of the problem. I reset IE8 by default, deleted and reinstalled java and flash and still no luck. I can't access a lot of pages now. I have the latest version and updates of Norton Internet security, no virus or threats and can not find the problem. It's something that the last update has changed in my system.

    Hi Rtechman,

    -What is the operating system installed on your computer?

    If you are using Windows 7, I suggest to run the troubleshooter for Internet Explorer and check to see if it helps you to solve the problem.

    To run the Internet Explorer troubleshooter, follow these steps:

    1. close all programs.

    2. click on Startand then click Control Panel.

    3. under system and security, click on find and fix problems.

    4. in the left pane, click view all.

    5. click on Internet Explorer Performance. This opens a new window.

    6. click Next.

    7. the resolution of the problems run and try to solve all the problems identified automatically. Click close.

    After that the store has run successfully, try to access the Internet again.

    Also, you try to access Internet Explorer in safe mode with networking and check that it works very well and post back the result. To start the computer in safe mode with network, restart both computers and keep tapping the key F8. Once you see the option to select the mode safe mode with networking, select it and press ENTER.

    Access the link to learn more about how to start the computer in safe mode: http://windows.microsoft.com/en-US/windows7/Start-your-computer-in-safe-mode

    In addition to run Internet Explorer in "no Add-ons" mode and check if it works well.

    An error may occur if an add-on is damaged or if an add-on conflicts with Internet Explorer. To check the THE same, run in mode without modules.

    1. Go to Start Menu > programs > Accessories > system tools.
    2. Click Internet Explorer (No Add-ons). Internet Explorer opens without Add-ons, toolbars, or plug-ins.
    3. Test Internet Explorer to verify that it works correctly.

    Post back and let us know the result.

    Thank you and best regards,

    Srinivas R

    Microsoft technical support.

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

  • Firefox does not save the proxy settings correctly

    I run Firefox 7.0.1 on Windows XP SP3 machine and I am behind a proxy server. We use a proxy script to my usual workingplace. However, on a trip, I have to choose a specific proxy servers IP address. After returning to my Office I change in the script. However, the next day, the settings are back to the IP address again, which means, FF does not save my settings correctly.

    Try:

  • Designation does not reflect the changes in the chain

    I have a situation where I have a couple of ArrayCollections and a string inside my template class (all are static public). I use the API of reflection AS to display all of the variables available in the model to the user and to choose one of them. Everything that the user selects is given to a custom with a Set accessor function component.

    If the user selects collection ArrayCollection, the custom component assigned as dataProvider of a chart inside controls. However, if the user selects the string variable, the component affects its value to a text of the label inside. Later, if I change the values in the ArrayCollection collection externally, the changes are reflected in the chart, but if I change the value of the string variable (external), the label is not displayed changes. How can I get through it?

    Here are the two sections of the custom component:

    /////////////////////////////////////////////////////////////////////////////////

    var puiblic : The object of the supplier;

    public function put dataElement(newData:Object):Sub

    {

    var dataName:String = newData as Chain;

    var type: Type = Type.forClass (Model.ModelLocator);

    var field: field = type.getField (dataName);

    ce .provider = field.getValue ();

    }

    ///////////////////////////////////////////////////////////////////////////////

    and later I do (in the same custom component)

    ////////////////////////////////////////////////////////////////////////////////

    var lbl:Label = new Dim;

    lbl. Data = this.provider as String;

    //////////////////////////////////////////////////////////////////////////////

    OK, so the problem comes from the fact that a static property cannot be thought binded MXML (text = "{ModelLocator.stringName}" ") and not thinking AS3 using ChangeWatcher or BindingUtils.

    Your ModelLocator class, isn't supposed to be a singleton? That would solve your problem.

    Otherwise, you will need to manually manage changes on your static property, and honestly I don't know how to do this...

  • Get-EsxImageProfile does not list the bundle version

    Hi guys,.

    may seem so trivial but on PowerCLI, I run the get-EsxImageProfile command, but I do not see numbers complete bundle on the columns 'name '.
    I tried enlarge powerCLI window but it stays the same.

    Any ideas?

    See screenshot

    Channel the output to Format-List and Format-Table - AutoSize

  • Video export of first 2 again... change first video... Still does not reflect the changes

    Hello world

    I have a good question, I hope that it is a question of creation, but it is also a question yet.

    First of all, I have my video project, for simple video segments, I added on my calendar, and I added a simple

    title to any (any length of videos)

    So far so good.

    So what I did was to export the project again, where it loaded fine, and yet I've worked on the provision of a simple DVD menu for the movie.

    I did about 2 hours on the DVD menu and then save the project again.

    ... then I realized as the video project in first needed some tweeking, so I went and did it.  I saved the project of creation

    and now, I am puzzled as what to do then.

    After I saved the newly tweeked creation project, I exported in yet, and of course, I knew this would happen, still open

    a new project with none of my menu system, I had made for the DVD.  Argh, now I am very disappointed... HOW would I go to get

    the DVD menu to work with the new tweeked first project?

    I guess I'm doing something wrong, and that there is a way to solve this problem.  I really really hope so.

    Thanks for any help you can offer.

    Dave.

    What do you mean by ' exported in yet? You encode a first M2V file, or did you use Dynamic Link to send the sequence of the organism to yet?

    If it is the former, open your original project yet, select the item imported from M2V and do a right click on it to select replace Asset. Navigate to the new encoding and select it.

    If it's the latter, you have no need to do something... unless you already transcoded the sequence in yet. If you did, still doing a right click of the sequence in the project Panel and select restore to the Original.

Maybe you are looking for