Get-hard drive on a single line of csv

Hello


I have to do a migration to a new san.

I want to be able to move everyting off the old san to the new, but I also need to separate files vmdk to different LUNS.
--------------
ex:

(VM1 (vmxfiles, Hd1, hd2, hd3) SAN1LUN1)--> (((VM1 vmxfiles) SAN2LUN0), ((VM1 hd1) SAN2LUN1), ((VM1 hd2) SAN2LUN2), ((VM1 hd3) SAN2LUN3))
--------------

I wish I could get a single line in a csv file:

--------------
ex:

VMName, VMXFILESLUN, HD1, HD1LUN, HD2, HD2LUN, HD3, HD3LUN
--------------

Is it possible to have this command, which overlooks several lines

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

Get-disk hard - VM * | where {$_.} DiskType - "Flat" eq} | Select the Parent, name, file name

Parent                                                             Name                                                              Filename
------                                                             ----                                                              --------
VM1                                                         Hard disk 1                                                       [DS1] VM1/VM1.vmdk
VM1                                                         Hard disk 2                                                       [DS1] VM1/VM1_1.vmdk
VM1                                                         Hard disk 3                                                       [DS1] VM1/VM1_2.vmdk

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

Instead, format to give:

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

VM1, name, hard drive 1, VM1/VM1.vmdk disk, Hard [DS1] 2, [DS1] VM1/VM1_1.vmdk, Hard disk 3, VM1/VM1_2.vmdk [DS1]

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

Thank you

Try something like that.

Note that we need to sort the table with the longest row at the top, otherwise Export-Csv has a problem.

$report = @()
foreach($vm in Get-VM){
    $row = "" | Select VM    $row.VM = $vm.Name
    foreach($hd in (Get-HardDisk -VM $vm)){
        Add-Member -InputObject $row -MemberType NoteProperty -Name $hd.Name.Replace("Hard disk ","HD") -Value $hd.Name
        Add-Member -InputObject $row -MemberType NoteProperty -Name $hd.Name.Replace("Hard disk ","LUN") -Value $hd.Filename
    }
    $report += $row}
$report | Sort-Object -Property {($_ | gm | Measure-Object).Count} -Descending | ` Export-Csv "C:\vm-hd-list.csv" -NoTypeInformation -UseCulture

Tags: VMware

Similar Questions

  • Get-hard drives - storage drives data store migrate between data warehouses

    Hi all


    Our current storage configuration with specially designed split-role of the bases of data storages (OS, LOG SQL, SQL DATA, APP, Exchange roles, etc.)  I do a storage store on my VMware Infrastructure and hoped to target only the disks of virtual machines that are on any data store and migrate them to another.  Rather new to PowerCli if you're wondering why the bellows of the command does not work and the reports that the file is locked.


    Get-hard drive - data store 'Datastore01 ' | Moving-hard drive - data store Datastore02

    If the machine virtual itself is made aware of the command?  Would I have to enumarte the virtual machines on the first data store and then target discs that everyone has and redirect it to the hard disk Move command?

    Thanks in advance

    Yes, you are banging in the sequence of commands trying to move a file on the data store without referencing the virtual machine. According to the State of the virtual machine (lit or not) of different things happen

    • VM power off - the disc is moved and the virtual machine is broken (the vmx file will always point to the original location for the HD that is no longer there)
    • Virtual MACHINE power - the disk is locked, so it cannot be moved (the error you have seen)

    Another thing to keep in mind is that the configuration of the VM is also on a data store, so if you want to move the entire virtual machine you can just move the hard drives

    If all the virtual machines on a data store have all their HDs on this data store then you can do something like

    Get - VM - data store 'Datastore01 ' | Move-VM - data store "Datastore02".

    To access the VM configuration, but also his records. If you have virtual machines where the disks into a single virtual machine, then you will have a little more work to do to sort the records that must be moved

    Get - VM - data store 'Datastore01 ' | Get-hard drive | Where-Object {$_.} FileName.Contains ("[Datastore01]")} | Moving-hard drive - data store "Datastore02".

    This is all virtual machines with a component (hard drive or configuration) on Datastore1, and then for each VM is all hard disks that are on Datastore01 and the Datastore02

  • 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}}
    
  • HP Envy Phoenix 850 - 180ST: adding a hard drive to a single SSD computer

    I want to add a SATA hard drive to serve as a backup to the SSD. Necessary cables do not seem in the present case. What do I need to do?

    The power connector is because it comes on the cables already connected to the power supply.

    You must obtain your own SATA data connector.

    Good luck

    I'm a volunteer and I do not work for, or represent, HP.
    ========================================================================
    If you feel that my suggestions helped you, please click on the thumbs-up symbol to say thank you!

    If they helped to solve your problem, please click 'Accept as Solution' to help others find similar information.

  • BlackBerry Smartphones getting contacts to display in single line mode / without company name

    Hello

    I have recently updated our 8310 CEO of 4.2.2.146 at 4.5.0.81 that changed how contacts are displayed in AB - 4.2.2 as a result displays each entry on one line, 4.5.0.81 shows name + company for each entry and takes two lines.

    Does anyone know how to change it online / if it's possible--two lines is a bit prettier, but habits are habits...

    Thank you very much

    Petar

    It's just not possible... I'm sorry.

  • Get-hard drive - Thin provisioning

    Hello

    I did a quick glance in PowerCLI (including extensiondata, excluding the Onyx) and in the community but couldn't find it.

    If I wanted to find the virtual HDs of the virtual machine, especially if it is thick or thin (it's easy) but more specifically what type Sub-epais/lazy, thick/eager, etc..

    I don't need a full script just one example of a VM - I can put in the fillers around her.

    Thank you

    As far as I know some of this information is only available/necessary when you create a vDisk.

    The following will give you some information

    $vm = Get-VM MyVM$vm.ExtensionData.Config.Hardware.Device | where {$_ -is [VMware.Vim.VirtualDisk]} | Select @{N="VM";E={$vm.Name}},@{N="HD";E={$_.DeviceInfo.Label}},@{N="Type";E={$_.Backing.GetType().Name}},@{N="EagerlyScrub";E={$_.Backing.EagerlyScrub}},@{N="ThinProvisioned";E={$_.Backing.ThinProvisioned}}
    
  • How to get the result of a single line in several columns

    I have a scenario where I asked five different columns in a table and it would still look back one line.

    So, for example: the query would be
     Select user1, user2, user3, user4 from table1 where tblkey= 2 
    So, this would mean 1 row with the value of their respective areas.

    In my code, I have a common function I can call to send an email to the list of people (User1, User2, user3, user4).

    So rather than call this function each time for each user, is there a way I can display the output to 4 different rows and use the loop For to call this function only once.

    In this way, the loop For running 4 times (if not nulls for all users) and call this function of e-mail.

    Really, I'd appreciate if someone could give me an idea of this scenario.

    Thank you
    AR

    If the number of columns is fixed you may be able to use this:

    SELECT  DECODE
            (
                    RN
            ,       1,USER1
            ,       2,USER2
            ,       3,USER3
            ,       4,USER4
            )       AS USERS
    FROM    TABLE1
    CROSS JOIN (SELECT ROWNUM RN FROM DUAL CONNECT BY ROWNUM <= 4)
    WHERE   TBLKEY = 2
    

    This UN-pivot results.

    Here's an example of it in action:

    SQL> CREATE TABLE TABLE1
      2  (
      3          TBLKEY  NUMBER
      4  ,       USER1   VARCHAR2(1)
      5  ,       USER2   VARCHAR2(1)
      6  ,       USER3   VARCHAR2(1)
      7  ,       USER4   VARCHAR2(1)
      8  );
    
    Table created.
    
    SQL> INSERT INTO TABLE1
      2  SELECT  ROWNUM
      3  ,       SUBSTR(OBJECT_NAME,1,1)
      4  ,       SUBSTR(OBJECT_NAME,2,1)
      5  ,       SUBSTR(OBJECT_NAME,3,1)
      6  ,       SUBSTR(OBJECT_NAME,4,1)
      7  FROM    ALL_OBJECTS
      8  WHERE ROWNUM <= 10;
    
    10 rows created.
    
    SQL> SELECT * FROM TABLE1 WHERE TBLKEY = 2;
    
                  TBLKEY USER1      USER2      USER3      USER4
    -------------------- ---------- ---------- ---------- ----------
                       2 I          _          U          S
    
    SQL> SELECT  DECODE
      2          (
      3                  RN
      4          ,       1,USER1
      5          ,       2,USER2
      6          ,       3,USER3
      7          ,       4,USER4
      8          )       AS USERS
      9  FROM    TABLE1
     10  CROSS JOIN (SELECT ROWNUM RN FROM DUAL CONNECT BY ROWNUM <= 4)
     11  WHERE   TBLKEY = 2
     12  /
    
    USERS
    -------------------------
    I
    _
    U
    S
    

    HTH!

    Published by: Centinul on February 24, 2010 11:21

  • How to get the values in a single line, without the help of the union

    Hello

    I have a table with the structure and the following data

    EmpID address phoneno emailid
    1001 xyz
    1001 1234234
    1001 [email protected]
    1002 23434
    1002 [email protected]
    1003 abcd
    1003 [email protected]
    1004 [email protected]



    I need to get a result in this format.


    EMP id address phoneno emailid
    1001 xyz 1234234 [email protected]
    1002 23434 [email protected]
    1003 abcd [email protected]
    1004 [email protected]


    I can do this by using the union, but who gives a performance of questions with a large table. I want to do it using any other way using lead or something, but with the relative to data complexity, I couldn't do it.

    Can someone help me please?


    Natarajan

    Published by: Nikita on December 3, 2009 15:50
    Select employee_id, max(address), max(phone), max(email)
    from emp
    group by employee_id;
    

    Max

  • Get a VM hard drives size

    Hello!

    I am trying to retrieve information about hard disks and storage of a VirtualMachine details.

    I get what I need using vm.getStorage () .getPerDatastoreUsage (); but unfortunately, the getStorage method does not work for older versions of Virtual Center (I get an exception caused by InvalidProperty).

    Is there another way I can get the size of the virtual disks to a virtual machine?

    For example, it would be enough to have something like the cmdlet Get-hard drive you can use with PowerCLI...

    Thank you very much!

    Filippo

    You can enumerate all the devices in the virtual machine. For each device, check if it is a hard drive and find the size.

    HTH,

    -Mani.

  • Windows problem for hard drive replacement

    I am trying to replace a hard drive in a HP d530 for a science teacher as the XP is a failure. He needs the XP until I finished preparing the Windows 7 and it has data on the XP and I put Windows 7 on the new hard drive and it has 80 GB. The old hard drive Windows XP and it is a 40 GB. I had two hard drives hooked when installing Windows 7. Windows 7, the name is the C drive and disk XP the D. I tried to start the hard drive of 7 single and it gives me an error of invalid system disk. Press a key to reboot. When I have two connected hard drives, windows 7 starts very well. A computer teacher wants to clone Windows 7 for another professor of science. He said, it won't help him with two hard drives connected. How can I get on the 80 GB stand-alone installation without having to reinstall Windows 7 Windows 7. I want to disconnect the hard drive from XP and just use the hard disk 7. I have the 7 and XP on separate hard drives. They are the two IDE hard drives. I need to get the new hard drive to boot by its self and windows 7 as a stand-alone installation.

    That's good news.

    I'm so glad you took in charge.

  • Best external hard drive of programs?

    Hello

    I am a Mac user and I am currently using:

    MacBook Pro (retina, 13 inches, end of 2013)

    2.4 GHz Intel Core i5

    8 GB 1600 MHz DDR3

    Iris 1536 MB Intel

    OS X El Capitan

    250 GB of storage.

    My Mac storage is almost full, and I am considering buying an external hard drive to free up space on my internal hard drive. However, I wanted to know if you can put programs on an external hard drive and if so, which is the best external hard drive for programs, for the cheapest price.

    I really don't want to pay more than 100 GBP.

    Between 50 and 70 GBP is my ideal price range, however, if there is an external hard drive that is absolutely amazing for a bit before, I can consider buying.

    If you cannot put programs on an external hard drive, which external hard drive is the best for a Mac?

    Furthermore, is it possible to add storage space for my internal drives?

    Thank you and I hope you can help me.

    Most of the programs broadcast their parts through several system directories.  A few programs I've seen work completely in a single directory.  Loading programs on "external" is delicate at best... unless the outside is a complete external operational system in-itself.

    With regard to external hard drives... people give me grief for continue to recommend, but...

    A single hard drive with a single disc is, in my experience, a compromise.  Mediocre quality disks combined with poor quality map interface and this card can do the contents of the drive not except through this controller... re-use of the disk outside this House requires reformat and loss of content.

    I use this external box http://eshop.macsales.com/item/OWC/MSTG800U3K/ that allows Exchange in all 2.5 in SATA drive.  The enclosure is of good quality, and you can get better quality discs to be inserted.  So when doen with one disk, exchange for another.  I use mine for player data and images, several clones/backups and test for the new OSXes drives and can use it to any number of other disks.

  • I changed my hard drive one that CPU to another in windows server 2003 64-bit enterprise version has been installed.now its prompting me to activate.what measures can be taken to activate with the old key

    Hello world

    I use windows server 2003, enterprise edition 64-bit. I changed the hard drive of one single processor to others. and now I face problem of activation. I'm not able to enter my old key to activate it. and its asking me to connect on internet.i must sign my user name and password to use internet.

    If anyone can suggest me how to get activated with over to connect to the internet and using the same old key for the hardware has changed...

    Hello

    1A, that the version of Windows is OEM copy?

    Check out this link to validate windows.

    I suggest you to validate windows and it would automatically activate the copy of Windows.

    What is the validation, and how does it work?

    http://Windows.Microsoft.com/en-us/Windows/help/genuine/what-is-validation

    I hope this helps.

  • Together-hard drive is not resize FS

    Hello!


    I'm trying to resize a VM with Set-disc drive.

    Resizing to the vmdk level works, but, as indicated in the documentation, if I'm not resize the disk to the operating system, the command should expand the FS.

    Well, it does not work...

    I'm trying to do this in different ways:

    - 1 get - VM $vmName | Get-hard drive | where {$_.} Name - eq "Hard Disk 2"} | Together-hard drive - CapacityGB 36 - ResizeGuestPartition-confirm: $false -> this process stucks

    2 - get - VM $vmName | Get-hard drive | where {$_.} Name - eq "Hard Disk 2"} | Together-hard drive - CapacityGB 36 - ResizeGuestPartition - GuestCredentials $credentials - confirm: $false -> I get this result:

    Hard drive set: 21/01/2016 17:30:22 Set-hard drive running the script in the operating system guest VM 'devvcli11 '.

    has failed: "the system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The specified disc '4' was not found.

    '

    At line: 1 char: 71

    + Get - VM Devvcli11 | Get-hard drive | where {$_.} Name - eq "Hard Disk 2"} | Game-HardDi...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo: InvalidData: (devvcli11:VirtualMachineImpl) [Set-hard drive], VimException

    + FullyQualifiedErrorId: Client20_RunScriptInGuestHelper_RunScriptFileInGuest_ScriptError, VMware.VimAutomation.Vi

    Core.Cmdlets.Commands.VirtualDevice.SetHardDisk

    WARNING: The system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The system cannot find the drive specified.

    The specified disc '4' was not found.

    3 - get - VM $vmName | Get-hard drive | where {$_.} Name - eq "Hard Disk 2"} | Together-hard drive - CapacityGB 36 - GuestCredentials $credentials - confirm: $false--> this command completes without error, but the drive remains with the old size


    Can someone help me?


    Thanks!

    What OS are you running inside the guest?

    Like the cmdlet Set - hard drive help States, "for a list of supported operating systems see the PowerCLI User Guide".

    Take a look at page 28, the help of custom Scripts to extend the supported operating system for vSphere PowerCLI Cmdlets

  • cmdlet New-hard drive

    This will create a HARD drive on the same DS as the VM...

    Get-VM-name $displayname | New-harddisk - CapacityKB (10GB / 1 KB)

    How can I make more than one HARD drive in this order?

    FOR EXAMPLE:

    HDD1: 10 GB

    HDD2: 5 GB

    Thank you!!

    You cannot create two hard drives with a single command. You will need to use at least two commands. In PowerShell 5.1 Release 2 new disk hard-cmdlet has a parameter of CapacityGB. So, you can use:

    $vm = Get-VM -Name $displayname
    $vm | New-HardDisk -CapacityGB 10
    $vm | New-HardDisk -CapacityGB 5
    
  • BUG? : Hard drive remove / Remove-VM [DO NOT DELETE]

    Hi guys,.

    I have 2 questions on a single code segment:

    $oldVM = Get-VM -Name $targetVMname

    Get - hard drive -VM $oldVM | Remove HDD of the -DeletePermanently -confirm:$false

    Remove-VM -VM $oldVM -DeletePermanently:$true -confirm:$false

    The problem is that just the VMDK is left later in the datastore VM folder. That is why "-DeletePermanently" is not entirely effective.

    Someone had this problem?  I know that the solution is to go in the way of creating a function where you specify the data store, the record and the name of the file to remove the orphan OS VMDK - but the above code should work!

    I even had the code to erase the disc trying first before deleting the entire virtual machine.

    But the operation said 'delete '.

    $vmclonespec.config.deviceChange [0] .operation = 'delete '.


Maybe you are looking for