Help with hard drives and the "switch" statement

All the

I was wondering if you could please help? It's probably more to do with "powershell" than powercli but are... What I'm trying to achieve is the ability to create a function that runs through all my VM - counts the number of hard drives by VM - crosses EACH hard drive and gives me the ability of each of them. He then returns to a csv file (which iknow how to do). The segment below is pretty well what I want, but I was wondering if there was a way to reduce the amount of code! I tried using a foreach statement, but got stuck (PS - the maximum number of hard drives of our virtual machines can have is 5)

I'm just using a switch statement, because that is what I "thought" answered the problem. However if there is a way I could get the same result without so much 'code' that would be ideal.

Switch ($vm.harddisks.length) {}

($vm.harddisks.length - eq. 1) {

($obj |) Ajouter-Membre Noteproperty 'Disk 1' ($vm.harddisks [0] .capacitykb))

}

($vm.harddisks.length - eq 2) {

($obj |) Ajouter-Membre Noteproperty 'Disk 1' ($vm.harddisks [0] .capacitykb))

($obj |) (Add - Member Noteproperty "Hard Disk 2" ($vm.harddisks [1] .capacitykb))

}

($vm.harddisks.length - eq 3) {

($obj |) Ajouter-Membre Noteproperty 'Disk 1' ($vm.harddisks [0] .capacitykb))

($obj |) (Add - Member Noteproperty "Hard Disk 2" ($vm.harddisks [1] .capacitykb))

($obj |) Ajouter-Membre Noteproperty "Hard drive 3" ($vm.harddisks [2] .capacitykb))

}

($vm.harddisks.length - eq 4) {

($obj |) Ajouter-Membre Noteproperty 'Disk 1' ($vm.harddisks [0] .capacitykb))

($obj |) (Add - Member Noteproperty "Hard Disk 2" ($vm.harddisks [1] .capacitykb))

($obj |) Ajouter-Membre Noteproperty "Hard drive 3" ($vm.harddisks [2] .capacitykb))

($obj |) (Add - Member Noteproperty 'Hard Disk 4' ($vm.harddisks [3] .capacitykb))

}

($vm.harddisks.length - eq 5) {

($obj |) Ajouter-Membre Noteproperty 'Disk 1' ($vm.harddisks [0] .capacitykb))

($obj |) (Add - Member Noteproperty "Hard Disk 2" ($vm.harddisks [1] .capacitykb))

($obj |) Ajouter-Membre Noteproperty "Hard drive 3" ($vm.harddisks [2] .capacitykb))

($obj |) (Add - Member Noteproperty 'Hard Disk 4' ($vm.harddisks [3] .capacitykb))

($obj |) (Add - Member Noteproperty 'Hard Disk 5' ($vm.harddisks [4] .capacitykb))

}

write-host $obj

}

Once again thanks in advance

Munster99

Try something like this

$i = 1
$vm. Hard drives | %{
$obj | Noteproperty Add-member ('Hard drive' + $i) ($vm.harddisks [$i - 1] .capacitykb)
$i ++
}
write-host $obj

Tags: VMware

Similar Questions

  • Help with Hard Drive and registry

    Hey, it kinda turns out to be a long and difficult history, but I recently had a small problem that spread to a problem much bigger (and catastrophic).

    I had a problem with freezxing on my laptop (HP Pavilion Dv5 with the 64-bit version of Vista I think). I've tried a few things m ais it froze just in case. Finally I found someone who said they ran a registry cleaning program and that did the trick. I tried and I had no more freezing. Unfortunately, I connected an external hard drive and all hell broke loose. It froze and I turned off the laptop. I have it turned on and was greeted with this message:

    STOP: c000021a {Fatal System Error}
    The Session Manager failed to create protected prefixes system process terminate
    d unexpectedly with a status of 0x000003a (0x00000000 0x00000000).
    The system has been shut down.
    

    I tried to boot in safe mode and found:

    STOP: c0000218 {Registry File Failure}
    The registry cannot load the hive (file):\SystemRoot\system32\config\SOFTWARE or its log alternative.
    It is corrupt, absent, or not writable.
    

    Then, she went and made the collection of data, and that was all. After that, I tried the boot recovery option and that never worked. I searched internet and found a few people with similar, but never the same questions. Someone, somewhere, says something about execution of system restore after having access to the menu by pressing F8 at startup. I tried. It did not work. I pressed F8 at startup upward and chose the first option. It has established a list of things to try. System Restore (and other options such as checking memory and bring up the command prompt) did not work because the C drive has been used. Large. I tried to use the disks that came with my laptop and I never once found while they were actually useful because I could never the laptop to run.

    Now, I wanted to try to use the command prompt. Never really had a chance. Now, when I start the computer I'm greeted by the inspiring message of hard drive are not.

    Sweet. Now, I'm a little stuck on what to try. I tried to reset the BIOS defaults and nada. I have no idea what it must try now and would love to help anyone.

    I would be very happy and I thank you for your time.

    It depends on how much you have to pay to get the new hard drive installed and running. Get a quote for a computer shop trust you.  So I think that if the computer has been done what you wanted to do before he went wrong.  If it was enough for you and the price of the repair is not too high (maybe less), I would. If the price is more than $ 200, I would start thinking about applying your money towards a new laptop computer, but that cheaper isn't always the best deal.  Do some research and try some mobile friends to see if it is fast enough for you and you enjoy the feeling. Stop in some stores that display laptops and taste. Laptops with dedicated video card memory will do better with the games.  If the games are starting to become important to you, consider a desktop computer instead of a laptop where you can buy a killer video card. I like the new Ivy bridge to intel for laptops so look for it.  This is the new family of Intel processors. I7 Ivy bridge is the finest, then the i5, then the i3.  You really need to sit with someone who knows computers and discuss your needs for the future and how you want to use your computer.

  • My hard drive and the Extras have plenty of space. Yet several times each and every day, I'm getting flashed "virtual memory minimum insufficient..." Virtual memory pagefile... "Any joy? Please help if you can. Thank you. Cecilia.

    Question

    I have another type of problem with Firefox

    Description

    My hard drive and the Extras have plenty of space. Yet several times each and every day, I'm getting flashed "virtual memory minimum insufficient..." Virtual memory pagefile... "Any joy? Please help if you can. Thank you. Cecilia.

    This has happened

    Each time Firefox opened

    Only a few weeks ago, (tried everything)

    Troubleshooting information

    ?

    Version of Firefox

    3.6.3

    Operating system

    Windows XP

    User Agent

    Mozilla/5.0 (Windows; U; Windows NT 5.1; en - us; RV:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)

    Plugins installed

    • -Adobe PDF plugin for Firefox and Netscape
    • Default plugin
    • Shockwave Flash 10.0 r45
    • Windows Presentation Foundation (WPF) plugin for Mozilla browsers
    • Java plug-in 1.6.0_07 for Netscape Navigator (DLL Helper)
    • Npdsplay dll
    • DRM Netscape Plugin store
    • DRM Netscape Object network

    Read about virtual memory here: http://www.ehow.com/windows-xp-virtual-memory/

  • I currently store my pictures on and an external hard drive.  Lightroom 6 was not able to find the picture momentarily files.  I inserted an external Flash DRIVE after removing the hard drive and the computer renamed the stick with the same drive letter t

    Redesign existing external hard disks and still 6 Lightroom able to find existing photos.

    I currently store my pictures on and an external hard drive.  Lightroom 6 was not able to find the picture momentarily files.  I inserted an external Flash DRIVE after removing the hard drive and the computer renamed the stick with the same drive letter that has been designated by Lightroom to store my photos.  I could go into my Windows 10 and reset the player to the letter that Lightroom has given at the beginning of the external hard drive.   However, I know this can happen again, if I connect any stick USD or another device, while the external hard drive is not connected to my laptop.   I found the information that I can do the new designation of the final drive by choosing a letter it is 1/2 way or higher in the alphabet.   I would like to turn an external hard drive on a strong letter, warns we hope this previous problem.   My question is, if I already have a lot of pictures on this external hardrive with the designation of the current drive, how it becomes a higher letter and have 6 Lightroom recognizes files, now under the new designation of drive letter without having to go to each photo individually and manually force Lightroom 6 find each photo.  It would take more time than I'd like to lose.  Is there a way to get just 6 Lightroom to recognize the new disk designation has changed and is able to find all of the existing files?

    I have read the ADOBE LightRoom 6 manual and seem not to be able to find anything on how to do it.

    Any help would be welcome.

    Thank you!

    So in Windows, you can select a drive like q letter (or any other letter you want only towards the end of the alphabet)

    Then in Lightroom, you can reconnect to the photos on q: the following instructions (see specifically 4 Figure and related text)

    Adobe Lightroom - find moved or missing folders and files

  • Pavilion dv6600ev: I would like to replace the HARD drive and the RAM in my HP laptop. I want to check compatibility

    Hello guys. I would like to replace the HARD drive and the RAM in my HP laptop. I would check the compatibility. For the momemt, I have 2 x 512 MB of RAM and a 160 GB HARD drive. Does anyone know the type of RAM (DDR1 or DDR2 most) and the accepted maximum capacity. Also the SATA port is a SATA I? Besides, I'm going to change the operating system (preferably in Win 7) so is there a driver?

    You can install DDR2-800 modules and they are the most widely available at this point, but the memory will run at 667 mhz speed.

    If it's 'the Answer' please click on 'Accept as Solution' to help others find it.

  • I need to reinstall my CS6 on my PC.  I installed it on this computer for 2 years now, but anyway half of subsequently moved to one of my hard drives and the other half is on the other.  I be sure to consider both drives off the coast and reinstall on the

    I need to reinstall my CS6 on my PC.  I installed it on this computer for 2 years now, but anyway half of subsequently moved to one of my hard drives and the other half is on the other.  I'm sure to remove both drives and reinstall on the larger hard drive?  I am a student and single MOM, and I can't afford the monthly subscription for the CC7.  If it does not somehow, I'll miss my classes.

    If the largest is the primary drive then it is safer than any other installation option, but all uninstall/reinstall can present problems.  If the software currently works very well, I would say that leave well enough alone if your future depends on software work.  Before you delete anything, remember to disable by opening an application and by choosing Help-> Deactivate.

  • My netbook does not read my disk even if his reading of my external hard drive and the dongle

    My netbook does not read my disk even if his reading of my external hard drive and the dongle

    Hello

    1. what operating system do you use?

    2 did you change on your computer?

    3. did you receive an error message?

    I suggest you to follow the links and check out them.

    Your CD or DVD drive is missing or is not recognized by Windows or other programs

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

    Your CD or DVD drive cannot read or write media

    http://support.Microsoft.com/mats/cd_dvd_drive_problems/en-us

    Hardware devices do not work or are not detected in Windows

    http://support.Microsoft.com/mats/hardware_device_problems/en-us

  • internal hard drives within the switching apparatus

    Switching of the internal hard drives in the machine. I have two internal hard drives, C and E of clarification and I replaced my C Seagate 360 with a TB Western Digital because of this hard disk failure false I bought, which I'm sure were a corporate scam to buy more stuff that is really unnecessary. My question is "how to pass these. My HP Pavilion Elite m9150f going in stupid mode on 3 to 5 times a year and I have to do a recovery and I found that doing the hard, it is happening in stupid mode in a very short time. I found is from the CD that it takes a little more, but the best way is to erase completely and reformat the hard drive and then do a clean install, so he prevents her from stupid mode for awhile, this one lasted 4 months but like you have probably understood it's time to do it again. However, as you know it takes 3 times as long to reformat TB as it does a 360 GB drive, so it's the root of my question. I have all my stuff on the E-Drive SG360 for backup, note here backup on this PC has never worked so I don't bother with the so-called machines back to top I just copy stuff I want to record on the E drive and make the ol' copy ' and paste to restore everything. Now because of the time it takes to reformat drive C TB I want to make the switch. Is it as simple as just their switching and pulling the PC with the recovery discs factory to perform RECOVERY and do my usual copy and paste of the Western Digital to now, E-Drive?

    Please someone with the know let me know

    Thank you very much, RickS

    Aparently, you can not RESPOND to your own message.

    No one answered so I went ahead and did it. Lost all learned but a lot on the partitioning of hard disks and all together, in addition to becoming the hard drive back to R & R until less than 6 minutes time to unplug the PC at the rear, turn 05:53, my best so far. but she is back to being usable was a day and a half.

    The answer to the question is when you put that there is nothing usable at all because the PC looking for the OS and boot any disk has. I had to start player, I chose so that I could erase and reformat the C drive and run the installation of the OS. Once he was done with that I had to choose again which drive start so I could erase and reformat the drive E then he would leave goes to the starting window when I turned it on.

    Simple answer is not a. Read above.

    RickS

    PS: I hope this helps someone.

    Hello

    Check with HP to factory reset of related problems.

    All the best Ricks!

  • Help with hard drive

    I have a problem with Windows 7 and recently bought a HP p6-2133w with Windows 7 installed, I need to download and to make operational a piece of software which is not compatiable. Wanted to Crash Windows 7 and install XP instead, but it was a no go. Can you help and tell me how to plant this hard drive. Also tried to install another hard drive and install the system and she always do it?

    Answers?

    Marv,

    Thank you very much. You can try to offer KUDOs as you like ;-)... I appreciate it. Please mark this as RESOLVED issue. In my view, that it was launched by another username of "marverdman". You have to login with this name to mark the thread.

    Frank

  • How can I reinstall Photoshop elements 7? I have the numbers series but bought 6 years ago. I have a new hard drive and the original link to reinstall but it doesn't work.

    I have a new hard drive and you want to reinstall Adobe Photoshop Elements 7. I know it's old but it works well for me. It of there in my orders with the serial number, but what do I do next?

    Buy a new, more up-to-date Photoshop elements?

    All the stuff sounds really complicated cloud creatives and seems very expensive.

    maureenart wrote:

    I have a new hard drive and you want to reinstall Adobe Photoshop Elements 7. I know it's old but it works well for me. It of there in my orders with the serial number, but what do I do next?

    Buy a new, more up-to-date Photoshop elements?

    All the stuff sounds really complicated cloud creatives and seems very expensive.

    Try to download from here:

    Download Photoshop Elements products | 9, 8, 7

  • Get several errors in the hard drive and the slowness of the system XP

    COMPAQ Evo N600c, has a lot to a lot of errors on the hard drive. Slow to load, slow to respond to commands, sites will freeze in the middle of the operation. A way to clean the system of mistakes without having to spend money (amount X). ?  Ran, Anti - Virus, also hard drive cleaner and have Windows SP3 update. Thank you, Thomas,.

    * original title - mistakes, mistakes, mistakes and Everwear *.

    COMPAQ Evo N600c, has a lot to a lot of errors on the hard drive. Slow to load, slow to respond to commands, sites will freeze in the middle of the operation. A way to clean the system of mistakes without having to spend money (amount X). ?  Ran, Anti - Virus, also hard drive cleaner and have Windows SP3 update. Thank you, Thomas,.

    Please be specific on what you mean by "far from many errors on the hard drive."  What kind of mistakes? Do you mean the drive read errors? Please quote the error message you get exact, verbatim.

    How many mistakes is "too much"? How many times they do they happen? They occur only when doing certain things or anything?

    If you really get a lot of the drive read errors, the drive is defective and must be replaced.

    But if you're talking about freezing, slow, etc. This is another question entirely, and I wouldn't call it 'errors on the hard drive. The little info you provided the mind, it is difficult to know what this problem is, but one of the things these days plussusceptibles is malware infection. What antivirus do you run (they are far from being just as good, and some of the most popular are among the worst). Do you also run an anti-spyware program? If not, it's * very * likelythat you are infected. I recommend that you download and run the free MalwareBytes AntiMalware to http://www. Malwarebytes.org/products/malwarebytes_free

  • Size of the hard drive in the solid state

    Hi, I was thinking about upgrading my hard drive on the stock of 320 GB for one SSD drive.

    But I'm not sure what one to get. I am considering a 128 GB Crucial one. Choose the height of 7mm we or 9.5 mm? That one will fit in my notebook? I bought a 9.5 mm OCZ before, but it was a very tight squeeze. I don't know if its supposed to be that of sense, though.

    Suggestions? Thank you.

    I suggest you refer to the user or the hardware of your laptop manual and you will get details on the description of SSD.

    Therefore, you can go for the SSD.

    Best regards

    Tanuj

  • HP G71: Install the new hard drive and the raw copy

    Hello

    My HP G71 is 64-bit, 4 GB RAM and hard drive WD320BEVT. The laptop has more than 5 years of service and I want to replace with a new hard drive while performing a raw copy of the current. I have a dual boot Win 7/Ubuntu installation I want to keep on the new hard drive.

    As I have not found a new HD of the same type and capacity, I would like to replace the current one with an another Western Digital 2.5 ", the IDE interface, but with a capacity of 0.5 to 1 TB (I choose one or the other).

    My questions:

    -can I install one of these hard drives on this laptop? They are compatible with the current BIOS/chipset?

    -If I make a raw copy of the 320 GB drive to the 0.5 or 1 TB, how would the current operating system partitions will be reflected in a higher capacity drive?

    -J' bought an IDE/USB interface adapter as well as to make possible the raw copy, could you recommend, if these questions have the THUMB, a good free to use software that I could use?

    Thanks for your help!

    Yes I use Kubuntu and tried several times to just the entire disk image and it does not reproduce partitions Linux and Grub, but when you try to start Linux it will hang and say can not find the prior specific hard drive. So now I just make a backup of Windows and reinstall Kubuntu from scratch. Much easier. I think there are also Linux backup programs you can use, but never really saw the need.

  • Dv5-1040ee: Updrade for the hard drive and the data movement

    I've recently updated by 10-32-bit Windows operating system

    I need advice on two things:

    1. I am currently on 160 GB - and planning to upgrade to a drive hard 500 GB or 1 TB with a 7200 RPM.

    Please let me know, what this laptop supports... (I'm in India

    2. need to move my Windows to the new hard drive, as is, without having to re - install.

    Need advice for the same thing.

    Appreciate your quick response.

    Concerning

    Baala

    Yes, it will support a 500 GB or HDD Terrabyte 7200 RPM 2.5 inch SATA. Your installation can be transferred to a new larger drive using cloning. There are several programs that can do of CLonezilla (free) to pay software like Acronis True Image. Need you a SATA to usb adapter to hold the new player during the clone process.

    https://www.YouTube.com/watch?v=PPoRMRzYHAg

    Post back if you need help most.

    If it's 'the Answer' please click on 'Accept as Slution' to help others find it.

  • FireWire devices are most recognized. External hard drive and the camcorder will not connect.

    My computer no longer recognizes the firewire devices that I connect to it.  The Device Manager shows the driver 1394 work very well.  I even deleted and reinstalled Windows XP.  My external hard drive so my camcorder are more recognized when I plug them cold or hot plug.  Two of them have worked very well for more than 4 years and now for some unknown reason, that they stopped just recognized.

    How can I get Windows XP to see again them?   I've tried everything.

    Hello Stevec5375.

    See the link below.  There is a fix for those running XP with multiple Firewire devices, thus causing a problem.

    http://support.Microsoft.com/kb/830987/en-us

    Please let us know if it did or did not help to solve your problem.

    See you soon

Maybe you are looking for