Get disc using Where-Object sizes

Hey guys,.

Im doing something really wrong here, but every time I run this command, all I get is maybe the VM property:

$VM | Where-Object {($_.)} Guest.Disks | Where-Object {$_.} Path - eq "C:\". »}). CapacityGB}

Any thoughts?

You can.

First loop through all the virtual machines in the $VM variable, and then extract the object that represents the C partition in the $a variable.

Once done, access you the properties through the $a variable

$VM | %{

$a = $_. Guest.Disks | Where-Object {$_.} Path - eq "C:\". »}

$a.CapacityGB

}

Tags: VMware

Similar Questions

  • Need help getting the Where-Object filter in the right place

    Hello

    I'm trying to filter local data warehouses, but I do not get the expected results.

    Code:

    Get-Datastore. Select @{N = "MON"; E={$_. Name}},

    @{N = "Total virtual machines"; E={@($_ | Get - VM). County}} |

    Where-Object {$_Name-Notlike "Datastore1 *"}

    Thank you

    As a general rule, you want to first filter when it is possible for greater efficiency in the pipeline.  Which is no exception here:

    Try:

    Get-Datastore. Where-Object {$_Name-Notlike "Datastore1 *"} |

    Select @{N = "MON"; E={$_. Name}}, @{N = "Total virtual machines"; E={@($_ | Get - VM). County}}

  • Trajectories of load balance LUNS, Where-Object error

    Greetings,

    I started to modify the script to:

    http://vmjunkie.WordPress.com/2009/01/29/balancing-LUN-paths-on-your-ESX-hosts-with-PowerShell/

    to adapt to our environment. We have our similar to VM LUN LUN labeled utility, but they do not have the same number of paths. Here are the instruction select where-object that I use:

    SNIP script:

    $luns = $VMHost | get-scsilun - luntype disc |

    WHERE-object {$_.} {ConsoleDeviceName-like ' / vmfs/devices/drives/vml * "} |

    WHERE-object {$_.} {CanonicalName as "vmhba0:0: *"} | CanonicalName sort-Object

    $firstLUNPaths = get-ScsiLunPath $lun [0]

    $numPaths = $firstLUNPaths.Length

    The script works very well on the first host in the cluster, but I get this error on each host subsequently:

    Err:

    Impossible to index in an object of type VMware.VimAutomation.Client20.Host.ScsiLunImpl.

    C:\hp\Tools\VM_Tools\Scripts\Pathing\Set_Cluster_SAN_Path_t.ps1:37 tank: 40

    + $firstLUNPaths = get-ScsiLunPath $lun [0 & lt; & lt; & lt; & lt;]

    Line 37 is:

    $firstLUNPaths = get-ScsiLunPath $lun [0]

    If I remove the part of the select statement:

    WHERE-object {$_.} {CanonicalName as "vmhba0:0: *"}

    The error disappears. Since it is part of the select statement that gets the VM LUN I really it works.

    Thanks in advance!

    Kevin

    Are you sure that $lun is a table when you get the error?

    Maybe there is only 1 object of ScsiLunImpl. Where the error index.

    You can try asking the type of the variable $lun

    $luns = $VMHost|get-scsilun -luntype disk|
    where-object {$_.ConsoleDeviceName -like "/vmfs/devices/disks/vml*"} |
    where-object {$_.CanonicalName -like "vmhba0:0:*"}|Sort-Object CanonicalName
    
    ($lun.gettype()).Name
    
    $firstLUNPaths = Get-ScsiLunPath $lun[0]
    $numPaths = $firstLUNPaths.Length
    

    He will say 'object []' when it's a table, but "ScsiLunImpl" when it comes to a single object.

    An easy way to fix this would be to make a table even when there is only 1 object

    $luns = @($VMHost|get-scsilun -luntype disk|
    where-object {$_.ConsoleDeviceName -like "/vmfs/devices/disks/vml*"} |
    where-object {$_.CanonicalName -like "vmhba0:0:*"}|Sort-Object CanonicalName)
    $firstLUNPaths = Get-ScsiLunPath $lun[0]
    $numPaths = $firstLUNPaths.Length
    
  • Try to resize C:\ on preproduction servers that are less than 59 GB using several Where-Object checks

    Hi people

    Im trying to increase all disks C:\ of different sizes for a uniform 60 GB.

    I found a thread in this community that attempts to automate it as follows:

    Get-hard drive - vm "my VM | where {$_.} Name - eq 'disk 1'} | Together-hard drive - CapacityGB 60 - ResizeGuestPartition-confirm: $false

    To confirm, the command works but the ResizeGuestPartition does not work, so I need to automate this later.

    For now the key is to get this working and it does not appear:

    Get-VM-Tag "preproduction" | Where-Object {$_.} Guest.OSFullName - like ' * Windows Server * "- and $_. PowerState - eq 'Receptor' - and ($_.) Guest.Disks.Path - eq "C:\". "- and $_. Guest.Disks.CapacityGB - lt 59)}

    Im trying to figure out how to use a hash table / script block to tell if the disc is "C:\". "and the size of this drive is less than 59 GB, then resize the disk. Before I resize the disks, I need to validate the im servers get back are indeed correct - for the moment, they are not as I checked inspected these variables manually through PowerGUI (excellent by the way).

    Even if I'm just trying to Get-VM-Tag "preproduction" | Where-Object {$_.} Guest.Disks.Path - eq "C:\". "- and $_. Guest.Disks.CapacityGB - lt 59} the result does not work and I think that its because it detects all the disks and then said there is at least one drive which is equal to "C:\". "and at least a drive that is less"Go 59 -"but I need it to be the same disk not different disks for obvious reasons, otherwise the result will always be wrong.

    LucD im sure you meet a reading, I would really appreciate your help

    Im trying to start searching for a cleaner steamer so that I don't have to run several lines of code to achieve the same.

    Much appreciated,

    Mike

    Try like this

    Get-VM-Tag "preproduction" |

    Where-Object {$_.} Guest.OSFullName - like ' * Windows Server * '- and

    $_. PowerState - eq 'Receptor' - and

    (($_. Guest.Disks | where {$_.} Path - eq "C:\". »}). (CapacityGB-le 59)} |

    Select name

  • I have the MG8220 printer and you want to print on a DVD disc using the top of the desktop software

    In the past, I have been using a desktop software to produce graphics and then print labels in paper. Using a model of a disk. Works very well with my printer ip4600.  Now with the MG8220 printer capable of printing on discs, how can I do this without copying an existing labeled disc?  I don't want to copy a disc but rather to print on a disc using a graph of ready scaled to fit on a disc.

    Thanks for any help.

    Hi excolprof,

    We only support printing to disc with Easy Photo Print software and my garden of Image provided.  We encourage you to try to use third-party programs, but as they are not supported, the only steps I can recommend would be to ensure that the paper size is set to CD disc within the software.

  • When I turn to the Chinese news site to read some news in China, I get only small square box size rather than Chinese characters.

    Reading emails and news in Chinese characters.


    For this monment, when I turn to the Chinese news site to read a few novelties in China, I get only small square box size rather than Chinese characters. Even when I received emails from my Chinese friends in Taiwan or China, written in Chinese characters, I can barely see small square boxes I have my emails. Please can you direct me to that Microsoft site where I can download Chinese characters if my emails or news paper site is in Chinese. Thank you.

    Hi Sebastian,.

    See if this helps:

    http://Newton.uor.edu/departments&programs/AsianStudiesDept/language/asianlanguageinstallation_XP.html

    see you soon,

    Steve

  • Windows Vista CD problems - "Windows cannot read the disc in the drive E:\. Make sure that the disc uses a firmat Windows recognizes.

    Original title: problems of Windows Vista CD

    Windows Vista Home premium. You want to burn on a CD - RW disc image files. Inserted the disc in the drive and got the message "Windows is unable to read the disc in the drive E:\. Make sure that the disc uses a firmat Windows recognizes. If the drive is not formatted, you must format it before you use it. "I can't get a dialog to come so that I could format. Not had this problem with a disc previous out of the box Memorex even.

    My problem has been resolved by the www.mydigitallife.info/autoplayautorun-not-working-or-missing-not-open-in-windows-vista/ procedure. The first element - material Detection service kernel - managed.

  • When I connect to the Internet, I get a message error "object does not support this property or method". Unable to do anything from there.

    original title: error messages
    As soon as I get on Explorer and on internet I get an error message "object does not support this property or method' am unable to navigate due to this message to appear on each movement.  Someone help?  Thank you

    Hello

    (1) do you have made no changes before this problem?
    (2) is this problem limited only with a particular website or any websites?

    (3) when exactly, you receive an error message when you use Internet Explorer or when the Internet connection?
     
     
    Method 1: If you receive script errors, you can read the following article and check if that helps.
     How to fix script errors in Internet Explorer on Windows computers?
    http://support.Microsoft.com/kb/308260

    Method 2: You can also read the following article and check if it helps.

    Can't access some Web sites in Internet Explorer
    http://support.Microsoft.com/kb/967897

    Warning: Please note that reset the settings of Internet Explorer running resets all of the settings defined by the user, including those established by the installed extensions, toolbars and other add-ons for IE by default. This includes all the security, privacy and settings area. Also this will erase browsing history, delete all temporary Internet files, cookies.

    Method 3: Networking in Mode safe
    Follow the link below and check if the problem persists in safe mode with network.
    http://Windows.Microsoft.com/en-us/Windows-Vista/advanced-startup-options-including-safe-mode

    Hope this information helps.

  • How do I get my windows to normal size

    original title: get my windows to normal size

    I installed a game on my computer today for my son which at the end of the big screen, while I uninstalled the game, I can not get my windows to get back to normal... the screens or huge! Help!

    Hello

    "Change screen resolution".

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-screen-resolution

    If this does not work, you may need to > go to the website of your computer manufacturer > look for the driver download Section > put your computer model number > find your operating system > select last graphics / video Chipset drivers depending on how it is formulated) > download and install > then change the resolution.

    Or try a system restore to before the problem:

    http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-system-restore/

    See you soon.

  • How to get the use of memoery of an individual application

    Hello

    Now, I'm developing an application like a task manager. And I looked through the api system, but I have not found any api

    who can get the use of memoery to an individual application. Is there an API for it? Such as what is being implemented in

    system management applications since OS6 that we can see the CPU usage and the use of memoery to applications.

    Anyone know who?

    Another question, applications storage which will be an application is just the size of the cod files, is that correct?

    Advanced thanks.

    Welcome on the support forums.

    There is no api for this. everything that is used in the options, it is not available to us.

  • How do I get the screen width and size of the screen of the Blackberry storm?

    Hi guys,.

    I use the following code for the image capture.

    Bitmap bitmap = new Bitmap (Display.getWidth (), Display.getHeight ());

    try {}

    Display.screenshot (aBitmap);

    }

    In 4.3.0 (8120 device), when we use Display.getWidth () and Display.getHeight () it gives 240 x 320 respectively which has the correct size of the device.

    But in 4.7.0 Blackberry storm, when we use it gives data(240x320) even where the size of the device screen real is 360 x 480.

    So when we capture the image in the storm he's only half of the image. And also when hard code us the image like it from 360 x 480 size is thrown exception.

    Please suggest is there a way to capture full screen.

    Thank you

    Thanks for sharing the result. You can mark the thread as solved.

  • Not reformatted, no installation disc used but old key.

    Recently, I replaced my hard drive and had to reinstall Windows.  I pulled the old product key from the registry and used on the new facility.  I don't have the disc that came with my laptop for installation, so I took the disc I bought to my Tower and allows to install windows on my new drive and used the product key provided with the version preinstalled windows came with my laptop.  Now, I get messages saying that I have to get a 'real' windows...  The two versions of windows were family premium 64-bit.  Is this being fixed?  How can I get windows using the key, that I got with my laptop and without having to buy a whole new operating system?

    Hello

    When you reinstall the operating system on a new hard drive the way you do that you use the product key located on the COA sticker on the underside of the laptop.

    If it is not there, look for it in the battery compartment.

    This is what it looks like:

    You probably need to I also do phone Activation and does not Demand of Auto, but brace yourself for a real person explain to the:

    "How to activate Windows 7 by phone ':

    http://www.SevenForums.com/tutorials/18715-activate-Windows-7-phone.html

    _________________________________

    And if you still have problems:

    You can contact the manufacturer of your laptop and ask them to send you a set of recovery disks to reinstall Windows 7.

    They should do this for a small fee.

    See you soon.

  • Error - Windows cannot read the disk in drive F:\-Assurez-vous that the disc uses a format Windows recognizes. If the drive is not formatted, you must format it before you use it

    Original title - Windows cannot read blank disc

    When I insert a blank DVD-R disc for burning, an error is indicated - "Windows cannot read the disk in drive F:\-Assurez-vous that the disc uses a format Windows recognizes." If the drive is not formatted, you must format it before you use it. "So I can't burn a DVD-R disc... But if I use the DVD-RW drive, it can be burned smoothly without any problems... Windows cannot recognize only the DVD-R disc... My DVD - RW driver is Sony Optiarc AD - 7280S. When I use Windows 7 without problem was found in the burning a DVD-R disc. But after using Windows 8, I can't burn a DVD-R disc. So please help me...

    Hello

    Thanks for posting your query on the Microsoft Community.

    According to the description, I understand that you have a problem with the disc.

    As you mentioned that you have tried the steps of troubleshooting mentioned in this thread.

    I suggest you run the Fix-it tool and check if it helps.

    This tool diagnosis and repair CD or DVD drive issues, when you can not burn or play CD or DVD discs when a disc is not found, not available or not connected.

    See the link below.
    https://support.Microsoft.com/en-us/mats/cd_dvd_drive_problems?WA=wsignin1.0

    As we have tried most of the troubleshooting steps to resolve this problem, and if the problem persists after you run the tool fix - it also. So, I suggest to get in contact with equipment manufacturers , because they will be the best person to help you.

    Hope this information helps. Please let us know if you need additional assistance. We will be happy to help you.

  • screen size of my email went mega big. How can I get that back to normal size?

    screen size of my email went mega big. How can I get that back to normal size?

    As I negotiated my e-mail screen with my cursor the screen size was bigger, enlarge the text.

    I don't know how this has happened.

    It happened a few times now and the screen is incredibly large, so I can't negotiate around it. Now watch the letters 64pt less or more.

    How can I get the screen back to normal?

    I tried to reproduce the movements of the cursor navigating round and edges, turn off the e-mail site and loging out.

    Nothing works.

    Help

    HA

    Use the CTRL + mouse wheel.

  • Get-hard drive | Measure-Object > list of objects

    I want to every amount of real "disk" 1 objects in the list / #. Rather than just the TOTAL SUM:

    Where does one would add or modify this script so it would list every-(VM-Name) of the object and the amount configured by VM?


    Thank you.. Please

    vSphere PowerCLI] C:\Program Files\VMware\Infrastructure\vSphere PowerCLI > Get -.
    VM 'xxx_name ' | Get-hard drive | where {$_.} Name - eq 'Disk 1'} | Measure-object - P
    CapacityKB-sum property. Select-Object amount

    Sum
    ---
    1317011456

    Try something like this

    Get-VM "xxx_name" |
    Select Name,
    @{N="HD1 Capacity";E={Get-HardDisk -VM $_ -Name "Hard disk 1" | Select -ExpandProperty CapacityKB}}
    

Maybe you are looking for