Help with script from beginner to the data store and hard drives

Hello

I am quite new to scripting, and recently, I created a monstrosity below.

The problem is with the results. I have no idea why in the results I get the name of the virtual machine and its data store over and over again until all disks are highlighted.

Any help will be very very much appreciated.

The script:

$raport = @)

Foreach ($i in (Get-Content "Y:\vms.txt"))

{

$rekord = «»

$vm = get-vm-name '$i '.

$dysk1 = $vm | Get-hard drive | where {$_.} Name - eq 'Disk 1'}

$datastore1 = $dysk1.filename.split("]") [0].split("[") [1]

$disks = $vm | Get-hard drive

{foreach ($disk in $disks)

$hd = «»

$disksize = ($disk. CapacityGB)

$hd += $disksize

{$rekord += $vm.name + ";" + $datastore1 + ";" + $hd}

$raport += $rekord

}

$raport | out-file 'Y:\dyski.csv '.

The results in csv:

VM1Name; datastoreName; 60; VM1Name:datastoreName; 50; VM1Name; datastoreName; 40

VM2Name; datastoreName; 45; VM2Name; datastoreName; 40

The results of dream in csv:

VM1Name; datastoreName; 60; 50 40

VM2Name; datastoreName; 45 40

etc.

Try like this

$raport = @)

Foreach ($i in (Get-Content "Y:\vms.txt"))

{

$rekord = «»

$vm = get-vm-name '$i '.

$disk = $vm | Get-hard drive

$datastore = ($disk | where {$_.}) Name - eq "disk 1" hard}).filename.split ("]") [0].split("[") [1].

$rekord = "$($vm.)". The name); $($datastore); $(($disk | sélectionnez-ExpandProperty CapacityGB)-join ' |') »

$raport += $rekord

}

$raport | out-file 'Y:\dyski.csv '.

Tags: VMware

Similar Questions

  • Script to list all the warehouses of data in a cluster, the virtual machines on the data store and the host of the virtual machine is on

    We have warehouses of data which are seen by more than one cluster. I need a script that will display:

    all stores of data seen by a cluster

    the virtual machines on the data store

    the host of the virtual machine is on

    the cluster the host is in

    The output I want is

    name of the store of data, the VM name, host name, the name of the Cluster

    any help would be appreciated

    Pretty sure this will do what you need:

    $report = @()
    Foreach($cluster in Get-Cluster){
        $datastores = $cluster | Get-VMHost | Get-Datastore
        foreach($datastore in $datastores){
        $vms = $datastore | Get-VM
        If ($vms.count -ge 1){
            foreach($VM in $vms){
            $object = New-Object -TypeName PSObject -Property @{
                  Datastore = $datastore.Name
                  VM = $VM.Name
                  HostName = $VM.VMhost
                  Cluster = $cluster
                }
            $report += $object
            }
    
        }
        }
    }
    $report | Export-Csv C:\Temp\VMs.csv -NoTypeInformation -UseCulture
    

    If you only want to shared data warehouses you can then use

    $datastores = $cluster | Get-VMHost | Get-Datastore | Where {$_.Extensiondata.Summary.MultipleHostAccess -eq $True}
    

    Hope this helps

  • Machines MSCS with RDM, how to change the data store?


    Hello world

    I'm having a problem of displacement of 2 machines with RDM disks.
    We have 2 guests ESxi 4.1 with virtualcenter, but no license for vmotion.

    This 2 machines is building a MSCS Cluster (Microsoft) (file server) with multiple disks (5) RDM,
    for a total area of 8.9 TB. Of course, for use with MS cluster, the WDR is with physical compatibility.

    The problem is that the local vmdk (and also rdm.vmdk files) for these 2 machines are on the local data store (a machine for each host) and I need to move them to the shared storage. But if I power off of a computer and trying to change with the ROW data store attached, I get an error because the VMFS of the commune dastore (block size = 1 MB) does not support these large files (up to 2 TB).

    I read a lot of articles
    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 1031041
    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 1026256
    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 1002511
    and a few other discussions of communities.

    In accordance with article
    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 1005241

    I tried to turn off the machine, remove the RDM, migrate to another data store, and then reconnect the RDM.
    There is a big problem with the last point, because I don't know how readd the RDM manually (vmfsktools?).
    I want to add an existing drive, but he was in local storage, and I don't want more no reference to the file in the local storage...
    According to the documentation of vmware for MSCS, the second node of the cluster disks can be added simply to add a drive existing and selecting the
    existing node. If it is no problem of shared storage, but the host cannot read local storage to another host...

    Any suggestion to migrate a computer virtual with RDM shared storage room? Thank you

    E' possibile disabilitare he LUN filtering per vedere UN RDM gia awarded:

    http://www.yellow-bricks.com/2010/08/11/storage-filters/

    Option da diabilitare temporaneamente in vCenter config.vpxd.filter.rdmFilter

    Andrea

  • PowerCLI 5.0 - get the data store and VM information

    I am trying to reach the list of virtual machines and their data warehouses in a specific cluster. It seems that the name of the data store does not... Any ideas?

    PowerCLI C:\Program Files (x 86) \VMware\Infrastructure\vSphere PowerCLI > Get-Cluster "NOMCLUSTER" | Get-VM-name * | Get-hard drive | Export-Csv - NoTypeInform

    c:\Scripts\***.csv creation

    Get-Cluster * | Get - VM | Select Name,
    @{N = 'Cluster'; {E = {Get-Cluster - VM $_}}, '

    @{N = "ESX host"; {E = {Get-VMHost - VM $_}}, '

    @{N = "Datastore"; E = {Get-Datastore - VM
    $_}}

  • Help with report VM (name MemoryMB NumCPU, data store, total size of the disk)

    I currently have a script (listed below) to the CR of query for each virtual computer and their allocated disks. The problem with the script is that when he meets a VM with disks on several data only stores the first data store is listed in the report. However, the total size of the disk is correct.

    Any ideas to fix this?

    $datastoreExp = @{N = "Datastore"; E = {($_ | get-datastore | select-object-1 premier).} Name}}

    $diskSizeExp = @{N = "Total disk"; E = {($_ | get-harddisk | mesure-objet-propriété CapacityKB-somme).} Sum}}

    Get - vm | Select the name MemoryMB NUmCPU, $datastoreExp, $diskSizeExp | Sort - property datastore, "Total disc | Export-Csv C:\Scripts\Reports\chargeback.csv

    I thought that was what you wanted, judging by your examples.

    In any case, no problem, the following should do the trick.

    
    $dsRegEx = [regex]"\[(\w+)\]"
    $report = @()
    get-vm | % {
         $vm = $_
        $vm.HardDisks | %{
              $row = "" | Select Name,MemoryMB,NUmCPU, Datastore, "Total Disk (Gb)"
              $row.Name = $vm.Name
              $row.MemoryMb = $vm.MemoryMb
              $row.NumCpu = $vm.NumCpu
              $row.Datastore = $dsRegEx.Match($_.Filename).Groups[1].Value
              $row.{Total Disk (Gb)} = "{0:N}" -f ($_.CapacityKB / 1Mb)
              $report += $row
         }
    }
    $report | sort -property Name, datastore,"Total Disk" |Export-Csv "C:\chargeback.csv" -noTypeInformation
    

    Since there are sometimes problems with the display of the hooks I have attached the script.

  • Script to fill in the date field and disable the form

    Hi all

    With little experience of Adobe I was tasked to create a set of PDF forms to use in my company. I drew using Pro forms, but I need a digital signature field that will fill a separate date field at the signing and also disable some of the fields in the form. For the moment I can get it to do one or the other, but I can't do both.

    Is there a script that I can use for these functions?

    Thank you

    KC

    As you have probably seen, there is an option on the signing tab to run a script when a digital signature is applied.

    Do what you have described what follows can be used (of course, you have to adapt the name of the field):

    this.getField("SignatureTime").value = util.printd ("mm/dd/yyyy", new Date()); Enter the date with the current date

    this.getField("Text1").readonly = true; The value of some fields read-only

    this.getField("Text2").readonly = true;

    this.getField("Text3").readonly = true;

    this.getField("Text4").readonly = true;

    etc.

  • What is a relationship between the data store and LUN?

    Hello

    I added 3 LUNS to a data store, but I can't list them since the MOB data store. Could someone tell me how to do it.

    Thanks in advance.

    Lee

    LUNS was formatted as VMFS and created a data store? If not, it will not be displayed. You can search for available LUNS that can be used to create a VMFS with QueryAvailableDisksForVmfs volume

    =========================================================================

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    Twitter: @lamw

    repository scripts vGhetto

    Introduction to the vMA (tips/tricks)

    Getting started with vSphere SDK for Perl

    VMware Code Central - Scripts/code samples for developers and administrators

    150 VMware developer

    If you find this information useful, please give points to "correct" or "useful".

  • I backed up all the data on external hard drive and did a clean install of xp pro. I can't find a lot of folders, files or programs.

    I'm looking for advice search to find photos, documents and MS Office applications, most seem to be missing. I had a large photo collection and cannot find a few hundred off more 4 000.

    How can I do to get the MS DOS programs? I have more drives. Is it possible to download the programs I had? MS will be able to see that the key is stored somewhere in my computer or external hard drive?

    A backup does not recover programs, only data.
    If you did a clean install of the program keys that are lost, so you have to install the origonal with all key media programs

  • You press on delete all selected items by browsing the data store and accidentally deleted a vmdk file which has the OS on it

    I accidentally deleted the vmdk file that has my OS on it by pressing the "Delete selected items" button in the window of browser data store. Is there anyway to recover? I have a snapshot that doesn't seem to work. There is still the VMDK file in there, but it has now 'delta' be added at the end. Now I get an error message when I try to turn on my VM saying that he doesn't get the vmdk file, of course.

    delta.PNG

    errorVMDK.PNG

    From the screen shots looks you have deleted only the descriptor hard files that can be recreated. To ensure this is the case, please provide a complete list of the files in the folder of the virtual machine and attach the last file.log of vmware(from the virtual work computer) to a post response to view required details.

    André

  • Boot XP, the XP CD and HARD drive failure

    Hi all

    I'm trying to fix a HP Media Center PC for someone, it runs Win XP MCE and after the POST, he returned to a blank screen with a cursor blinking _.

    I came to the conclusion that the Master Boot Record is damaged, however, when I insert a CD in XP to try to repair the startup using the recovery console, this request "press any key to boot from the CD" then, after a key, the response "checking your system configuration" or something like that flashes on the screen for a while and then the screen turns white.

    I took the HARD drive and run as an external drive to run chkdsk on the work and recovery partitions, the two discover ok. I also manually checked boot.ini, which seems to be in order from another system. I don't think that the user has tried to make strange changes to the system.

    I tried the non-destructive recovery, it made no difference. I have not tried the destructive version, because to be honest, I believe that this will only fix the operating system, not the boot sector.

    I'm really scratching my head over this one, so any help would be greatly appreciated please.

    Thanks in advance

    Gary

    I went back to check your original messages but don't see any mention one by using the DVD recovery which should have been created when the PC was new.  In this regard and the new disk, if you use the DVD recovery, they will partition the drive, install the OS and make the Partition Recovery for you and everything will end.  Then you'd be back to day 1 - your computer would be like from the factory.

  • Satellite A35-S159 - can I upgrade the CPU, GPU and HARD drive?

    Hey

    I have one in my possession and I wanted to make a good game.

    I don't know if I'll be able to cause. It hurts thinking may be able to put a processor duo or quad, and I do not know if the CPU will be able to support a really good graphics card, and I also think about changing hard drive.

    Any1 know what hard drives are compatible with what I can use which are good for games?

    Hello!

    I m wondering that you want to upgrade this old notebook. In my view, that a new laptop would be a better solution.

    On the CPU and GPU upgrade I can only say s is not possible and not Toshiba support. The GPU is soldered on the motherboard and t can be exchanged.
    I think you should read this: http://aps2.toshiba-tro.de/kb0/TSB9401AX0001R01.htm

    The HARD drive can be upgraded. This isn t a problem.
    AFAIK the A35 Satellite is equipped with a s IDE HDD and this means that you buy a drive HARD IDE interface up to 128 GB.

    Good bye

  • ProBook 450 G2 - change the map wifi and hard drive

    Hello

    I have a G2 450 ProBook and I would change the wifi card, to use the one that is supported by linux (Debian). I also want to replace the hard drive with an ssd.

    Is this possible without loss of warranty?

    Thank you!

    Kind regards!

    Bert

    Bert.

    These are the cards WiFi for your laptop.

    (15) WLAN module

    Atheros AR9485 wireless 802.11b/g/n 1 x 1 adapter 675794-001

    Realtek RTL8188EE 802.11bgn adapter Wi - Fi 709848-001

    Intel Dual Band Wireless-AC 3160 802.11 ac 1 x 1 WiFi + BT 4.0 combo adapter 710662-001

    Broadcom BCM943228HMB 802.11abgn adapter Wi - Fi 2 x 2 + Broadcom Bluetooth 4.0 adapter 730668-001

    Broadcom BCM43142 802.11 bgn 1 x 1 Wi - Fi + BT4.0 HMC combo adapter 753076-001

    Realtek RT8723BE 802.11 bgn 1 x 1 Wi - Fi + BT4.0 combo adapter 753077-001

    Intel Dual Band Wireless-AC 7260 802.11 ac 2 x 2 WiFi + Intel Dual Band Wireless-AC 7260 BT 4.0

    adapter combo 756753-001

    Your manual here.

    http://h20566.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/manualsResults/?sp4ts.oid=6943826&spf_p.tpst=psiContentResults&spf_p.prp_psiContentResults=wsrp-navigationalState%3Daction%253Dmanualslist%257Ccontentid%253DService-and-maintenance%257Clang%253Den&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken

    If you replace the WiFi with the one who is not listed, you may receive an error when it starts.

    You also have the option to add a mini SSD m2 card.

    Watch your videos repair here.

    http://h20464.www2.HP.com/results.htm?SID=6943826&MEID=BFEAE0A5-A6BD-4541-BA9F-32A9F9567EFA

    REO

  • Need help with javascript used to check the data in the mandatory radio button fields

    required_fields

    I get a syntax error (SyntaxError: missing: after the id property 17; at line 18).  I am trying to run a script to verify data in all the fields required radio button before letting the user to submit the form (or save).  Here is the code I use:

    var AllRequiredFieldsSet = true;

    for (var i = 0; I < this.numFields;i++)//loop through all form fields)

    {

    var fldName = this.getNthFieldName;

    var currentFld = this.getField (fldName);

    if(currentFld.type=="radio")

    {

    All the radios that are needed to see if the user filled their

    if(currentFld.Value=="OFF")

    AllRequiredFieldsSet = false; one of the option boxes has not been selected, this form cannot be sent

    }

    }

    If (AllRequiredFieldsSet is false)

    App.Alert ("all the required areas have not been met");

    on the other

    this.submitForm ({cURL"mailto:EMAILADDRESS@gmail.com", cSubmitAs: "PDF"});

    Miss me not all media... Any ideas on what I'm missing?

    Thank you! Judy

    These two lines should fix things:

    var fldName = this.getNthFieldName (i);

    ...

    if(currentFld.type=="RadioButton")

  • Help with 3-d positioning using the z (forward and backward)

    I have several compositions nested in my project OVER a good bit of photoshop layers. I notice every time I post my layers/pre-comps using the z axis in my main composition (forward and back) I can't say if they are all using the front view, I can only say that she was moved when he disappears behind another layer. HOWEVER when I go the main composition that contains all of the items, I can see how it looks 'really' in rendered previews, as if all of a sudden I see exactly where I placed the layers, and it is really misplaced. Why can I not see this before I go? And why didn't he show me this point of view in the first place?

    FYI: I see the side/top view layers, but I does not help me much because I can't tell what the front looks like.

    Thanks for a quick response! I thought about it, the answer is very simple: I do not have the 'Active camera view', which would have enabled to see exactly how I was positioning my diapers. I got it on the 'front'. When the "façade" is actually useful?

  • Download file from web to the data store

    I have a link direct 4 GB (MSSQL 2008) - and I need to put it in vSphere 4 DataStore

    How can I directly without having to download the file on my computer?

    Thanks in advance

    ESXi 5A command wget, I think it should exist in ESX 4

Maybe you are looking for

  • Satellite M45: Windows XP does not start when you click on the user name

    I have a portable Satellite M45 in XP service pack 2.After starting the PC, he gets that windows journal under the screen, I click on connect my name and nothing happens. I have completely reinstalled the operating system, updated all drivers etc, an

  • Apple USB20 HubPort@fd120000

    AppleUSB20HubPort@fd120000 keeps coming up as a warning of the notification of fault overcurrent. APPLE says that (as ALWAYS) the logic board is defective. They are happy to replace the old logic board with what I assume to be a logical "renovated" C

  • HP Pavilion g6-2200sx: AudIo Drivers

    Sir I can't get Audio drivers for HpPavilion G6 - 2200sx Notebook Pc Pleas help me

  • Upgrading RAM on a Touchsmart 610-1120

    I have a Touchsmart, Touchsmart, 610-112it and I want to know hot to upgrade the supplied 4 GB of RAM. Which is the exact component of RAm should I buy to update to 6-8 GB? How to install it? Thank you

  • Coprocessor Pavilion dv9700 w / win 7

    I have a HP Pavilion dv9700, who has 32-bit windows 7 is installed. When buying this laptop came pre-installed with 32-bit windows Vista.I installed windows 7 more early this year. Everything was working fine until last week when I noticed that the l