define an id scsi for a disc newly added for virtual machines via script

Hi Experts,

I used the script below to add disks to several virtual machines
http://blog.mattvogt.NET/2013/03/14/PowerCLI-mass-add-hard-disks/

But currently our requirement for change as if we must add 3 2 GB drives, the disks must the controller use SCSI (1:0) - (1:2)

And next bunch of disks, for example, should use use SCSI (2:0) - (2:2).

Y at - it an option to set the SCSI ID when adding new disks.
Please let me know if there is nothing we can achieve through scripts.

Thanks in advance.

Kind regards
Sourav

Try this new version, it works for me in my test environment

### Get VM/Disk Count/Datastore information ### $vmname = Read-Host "VM Name to add disks to"$num_disks = Read-Host "number of disks to add"$ds = "Oracle DB Farm Datastore Group"$format = Read-Host "Disk Format (thin, thick, EagerZeroedThick)"$size = Read-Host "Disk Size (GB)"

$vm = Get-VM $vmname$datastore = Get-DatastoreCluster -Name $ds

### Add $num_disks to VM1..$num_disks | %{  Write-Host "Adding disk $_ size $size GB and format $format to $($vm.Name) on datastore $datastore"

  if($_ -eq 1){      $hd = New-HardDisk -vm $vm -CapacityGB $size -Datastore $datastore -StorageFormat $format      $hd = Get-HardDisk -VM $vm | Where {$_.ExtensionData.Backing.UUid -eq $hd.ExtensionData.Backing.Uuid}      $ctrl = New-ScsiController -Type Paravirtual -HardDisk $hd  }  else{      $hd = New-HardDisk -vm $vm -CapacityGB $size -Datastore $datastore -StorageFormat $format -Controller $ctrl    $hd = Get-HardDisk -VM $vm | Where {$_.ExtensionData.Backing.UUid -eq $hd.ExtensionData.Backing.Uuid}  }}

Tags: VMware

Similar Questions

  • Don't define the default directory for virtual machines

    Use VMware Player 3, how can I set the default directory for the VMS to be opened or created?

    Concerning

    Marius

    Open the preferences of the user (on Windows, % APPDATA%\VMware\preferences.ini).

    You want to add OR change the following line:

    -prefvmx.defaultVMPath =

    If this key is not in the file, add it and the full path that you want as the default value, the value on the right side

    -prefvmx.defaultVMPath = "C:\Thanksgiving\Ate\Too\Much".

    Now that the player can create virtual machines, it would be nice to have the user interface to specify the default directory for put/get those VMs

  • Folder path as a VM property - for virtual machines in a paralytic

    Hello

    I used the new-viproperty of LucD script to create a folder for each virtual computer property in my inventory. It works perfectly well for virtual machines, but not for virtual machines in a paralytic as these do not have a 'record' in powercli property. they report a $null value.

    Would be much appreciated if someone can help me to modify this script so it creates a VM property for the VMS and VMs in a paralytic?

    http://www.lucd.info/2012/05/18/folder-by-path/

    01

    02

    03

    04

    05

    06

    07

    08

    09

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    New-VIProperty-Name'BlueFolderPath' -ObjectType 'VirtualMachine'-Value{

        param($vm)

        functionGet-ParentName{

            param($object)

            if($object.Folder){

                $blue= Get-ParentName$object.Folder

                $name= $object.Folder.Name

            }

            elseif($object.Parent -and$object.Parent.GetType().Name -like"Folder*"){

                $blue= Get-ParentName$object.Parent

                $name= $object.Parent.Name

            }

            elseif($object.ParentFolder){

                $blue= Get-ParentName$object.ParentFolder

                $name= $object.ParentFolder.Name

            }

            if("vm","Datacenters"-notcontains$name){

                $blue+ "/"+ $name

            }

            else{

                $blue

            }

        }

        (Get-ParentName$vm).Remove(0,1)

    }-Force| Out-Null

    Check if the new version works for you.

    New-VIProperty-name 'BlueFolderPath' - 'VirtualMachine' - value {ObjectType

    Param ($VM)

    Function Get-ParentName}

    Param ($Object)

    if($Object.) {Folder)

    $blue = get-ParentName $object. Folder

    $name = $object. Folder.Name

    }

    ElseIf($Object.) VApp) {}

    $blue = get-ParentName $object. VApp.ExtensionData.ParentFolder

    $name = $object. VApp.Name

    }

    ElseIf ($object - is [VMware.Vim.ManagedObjectReference]) {}

    $folder = get-VIObjectByVIView - MORef $object

    $blue = get-ParentName $folder. Parent

    $name = $folder. Name

    }

    ElseIf($Object.) Parent - and $object. Parent.GetType (). Name - as a ' file * ') {}

    $blue = get-ParentName $object. Parent

    $name = $object. Parent.Name

    }

    ElseIf($Object.) ParentFolder) {}

    $blue = get-ParentName $object. ParentFolder

    $name = $object. ParentFolder.Name

    }

    If ("vm", "Data centers" - notcontains $name) {}

    $blue + "/" + $name

    }

    else {}

    $blue

    }

    }

    (Get-ParentName $vm). Remove (0.1)

    } - Force | Out-Null

  • Wonder average CPU for virtual machines

    I have a supermetric that gives me the average demand of CPU for virtual machines.

    It works as set below:

    avgN($R40:A2055,3) / avg($R40:A2030)

    R40 is the data center - A2055 is the attribute of MHz CPU demand.

    A2030 is powered on virtual machines in the data center.

    Is it possible for me to write this formula without having to divide it by the total number of virtual machines in the data center?

    Is 'average' looks should do.

    vCenter.jpg

    Fix.

  • Use the diskette of esxi for virtual machines

    Hello
    I would like to set up a lab and I have hp g6 server but just with a single 600 GB sas disk
    is it possible to install esxi on it and also use it as a storage device for virtual machines on?
    I know that I can install esxi on a cool drive but if what I've said, it's possible I prefer to use that
    Thank you very much

    It's true.

  • Free version of ESXi can support for configuration of start and stop virtual machines via vSphere Client?

    I have read and found some documents on ESXi.

    According to the documents, I know that ESXi free version does not support some advanced virtual machine configurations and does not support write to ESXi host permission. But when I download ESXi from vmware.com, I can't find the free version. He will always be a trial of the licensed version edition because I can always do the configuration of start and stop virtual machines via vSphere Client installation. I can also run scripts (lamw) pl in vMA to stop the ESXi host (authorization to write ok?)

    Then I confused. How can I get the really free version of ESXi? Or will the free version after 60 days of evaluation?

    Start/stop above configuration is in vSphere Client via 'Configuration'-> "start/stop VM"-> "Properties"... «-> "Allow the virtual computers start and stop automatically with the system" actions setting and stop virtual machines can be configured to "comments"turn off computer"or"Suspend".» Can any body tell me if it's supported by ESXi free edition?

    Is the free version of vSphere Client too? Because when I use the vSphere Client, he told me that I have 60 days of evaluation. This confused me again. I think that vSphere Client is always free, am I right?

    Any suggestion or advice is much appreciated.  _

    Micky

    Configuration of start and stop virtual machines is available with the free version and licensed, with the free version you would be configured everything via vSphere Client, where as with a licensed version, you can optionally use scripts to configure it and also issue restarts/stops using scripts.

    Second, shutdownHostViaSOAPAPICall.pl for the version licensed and free of ESX (i), this script will work in both free and licensed because it uses direct SOAP calls emulating the vSphere Client communication. Take a look at the documentation for details, but this of course is not supported by VMware.

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

    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

    VMware developer community

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

  • 1 or 2 processors? 32 or 64 bit? for virtual machines

    I had a discussion with the network administrator about using 2 processors and OS 64-bit for virtual machines.

    It uses 1 proc and 32-bit on Proliant G5 servers for virtual servers ordinary.

    When it will be beneficial to use 2 procs and 64 bit?

    THX.

    Hello.

    When it will be beneficial to use 2 procs and 64 bit?

    It will be useful to use 64-bit when you have an application that you want to run 64 - bit, and it will be useful to add a second processor when you discover that a vCPU is not enough.  If by 'regular' virtual servers, you're talking low-end Windows servers, then the 32-bit single vCPU approach will be generally better.  Without knowing more about your applications or operating systems, it is difficult to give a more precise answer.

    Why do you think that you might need for 64-bit or 2 vCPUs?  Can you elaborate on what you put on foot?

  • Get-stat - disk for virtual machines on NFS data warehouses

    Hi all

    Through work for VMs on NFS data warehouses get-stat-disc?

    $myVM | Get-stat - disc

    Doesn't seem to work for VMs on NFS data warehouses, but that works for VMs on VMFS data warehouses.

    After a presentation of VMware to http://webcache.googleusercontent.com/search?q=cache:h78Db7LqHcwJ:www.slideshare.net/vmwarecarter/powercli-workshop+%2Bget-stat+%2Bnfs & cd = 2 & hl = in & ct = Europeans & gl = at the & source = www.google.com.au

    «WARNING: NFS performance statistics are not available (to come in a future version of vSphere).»

    When these statistics are available for NFS data storage?

    Kind regards

    marc0

    The answer is in the property of instance data that Get-Stat returns.

    (1) get-Stat ==> canonical name of the LUN on which disk the hard

    (2) get-Stat virtualdisk ==> The SCSI id of the virtual disk inside the VM

    (3) get-Stat data store ==> the name of the data store

    (1) you give statistics for view virtual machine i/o activity starting from the LUN. For a VM with several virtual disks on the same data store, this will display the total IO statistics. And it will also include i/o generated by another VM on the LUN as swap, Flash files related...

    (2) gives statistics for 1 specific virtual disk of your virtual machine

    (3) statistics of e/s of your VM to a specific data store. Interesting when you have a store of data with multiple extensions (multiple LUNS)

    I hope that clarifies it a bit.

  • SRM failover for virtual machines but not all VMDK disks to include

    Hi, I have a number of VMs that need failover protection, but not all the VMDK disks must be included when switching to the opposite site. For example, a virtual machine can have 3 discs and players only need 1 & 2, switch to the recovery site - SRM can be configured to ignore the 3rd disc?

    Thank you

    I was not aware of a fact that replied vmdk cannot be detached. I think that this is normal.

    Why you are replicating data, you do not need? You can place these VMDK on LUN not replicated?

  • Correct allocation of the vCPUs for virtual machines

    Hi all

    We have a physical server with 4 x Quad Core XEON E7310 1.6 GHz CPU

    VMware ESX 3.5

    We have 3 VMs that are assigned to the server

    VM1 (Production Server) as a result of config

    4 vCPUs, 16 GB of RAM and works according to:

    OS - Windows Svr 2008 R2 (64-bit)

    MS SQL Server 2008 (64-bit) (a database with the data of a line and two newspapers file)

    IIS7 with only a single application of ASP .NET (the App-based eXpress Foundation (XAF) from DevExpress) running in Classic .NET AppPool (a work process)

    Connection string Web Application points to the database on the same server (local)

    Web app has a userbase of around 250 users

    VM2 (Dev server) is the same as VM1 except it has only 8 GB of RAM

    Now 4 x 1.6GHz Quad Core CPU = 4 x 4 x 1.6 GHz = 25.6 GHz

    VM1 received 16GHz (reserved) and can use available CPU if necessary.

    Our problem is that when we don't have 10 users on VM1 it grinds to 80-100% CPU usage.

    Usually just open the app on VM1 is slower than if I use a laptop as the server.

    What can we do to improve the speed of VM1?

    Thank you!

    2 things.  DISC is your problem, not CPU.  It can run at 100% CPU, but it's probably because that the e/s DISK is queued up, and thus the CPU is waiting for data.

    try to reduce the CPU at only 2 vCPU, not 4.  More CPU for physical machines working, but the virtual computer without CPU more due to the work of how virtual machines (the same problem applies to any product of virtualization).

  • Search for virtual machines with function "Shared Folders" (HGFS) running

    I'm looking for advice on creating a script to find all VM with HGFS running, or where the service is actually used.

    Apparently, VMware posted the notice of security VMSA-2016-0001 | United States yesterday and my security people are panicking.

    Any information you have would be useful.

    Thank you

    Ludi

    The only way I know is questioning the guest operating system itself and check the registry path:

    HKLM\System\CurrentControlSet\Control\NetworkProvider\Order

    and check if the value string ProviderOrder hgfs, vmhgs or vmhgfs.

    You should remove these values and restart the virtual machine for the change to take effect.

    Wise PowerShell:

    $VM = get - VM NameofVM

    $Reg = [Microsoft.Win32.RegistryKey]: OpenRemoteBaseKey ("LocalMachine', $vm.extensiondata.summary.guest.hostname")

    $RegKey = $Reg.OpenSubKey("System\CurrentControlSet\Control\NetworkProvider\Order")

    $RegKey.GetValue ("ProviderOrder")

    VMware KB: Guest Windows cannot update hgfs.dat or vmhgs.dat

  • How everyone counts the total amount of GHz for virtual machines on a host-cluster?

    Hello

    I want to do some basic sizing and I may\may do not go the way to write about it.  For example, suppose I have a cluster of 4 nodes with a total of 200GHz and 1 TB of RAM on all four hosts with 100 VM.  How can I get the total amount of GHz\Memory that each virtual machine is configured with (not necessaryly to aid real-time) so that I can workout or demonstrate what fits on one or two hosts in the cluster, for example?

    Thanks for your help and advice in advance

    You can do this via the inventory tool called RVTOOL which allow you to do an inventory of all your virtual machines and hosts with the resource assigned and served. hope, it will help you.

  • Attached device PCI host to query for virtual machines

    In the web client, on a host, we can see in the peripheral PCI if one or several virtual machines are attached to it. The field is called "VMs using it."

    I was passing through the API Explorer but unable to find a way up to even with Orchestrator - to find out if a host PCI device is to be used by any machine virtual or not. Is this possible?

    If anyone is interested, this is the solution;

    var features = host.configManager.graphicsManager.graphicsInfo;

    for each {(device in devices)

    If (device.pciId.match("46")) {}

    System.log (Device.VM);

    }

    }

  • What is the type of object to use for virtual machine model in the Points of Extension?

    Hello

    I added my plugin point of extension vsphere.core. ${objectType} .monitorViews. My plugin is for all types of objects (vm, file, vApp, resourcePool, etc) except the model of the virtual machine. My understanding is that the vm object type would be required for the virtual machine template, but that doesn't seem to be the case. Am I missing something here? Should the plugin appear for the model of the virtual machine when I use the vsphere.core.vm.monitorViews extension point?

    Thanks in advance.

    Kind regards

    Ashutosh

    Sorry, I got confused by your original question. ExtensionPoint id you are looking for is the one for adding views a model virtual machine monitor tab:

    model.monitorViews vSphere.Core.

  • PowerCLI script for the deployment of virtual machines via the model using customizations comments

    Hello... I hope someone can give me a script that will do the following:

    (1) provision VMs in vCenter template (I need 125 + VMs created in the next day or two)

    (2) use the existing customizations of comments in vCenter

    (3) let me enter data warehouses available to be created on the virtual machines.  Example: I want that VMs on warehouses of specific data as LUN2, LUN5, LUN6, LUN12, LUN1, etc...  However, the script must have the ability to know when a data store is near the threshold of capacity, say 90%, so it can use one of the other warehouses available, identified in the script... similar to storage profiles.  We still have to adopt profiles storage but plan to do so once upgraded us to v5.1 in the next month or two.  We hope that this will help us keep our replicated LUN more organized during the use of SRM and copy to remote groups, our team of storage's configuration on 3PAR.


    Additional information: I will use 2 styles... Windows XP and Win7.  Their respective sizes are 40 and 60 GB due to all applications for stable DR.  Data warehouses are ea 500 GB.

    Please let me know if additional information is necessary... Thank you!!!

    Charles

    No, unfortunately you cannot specify a folder like this.

    You'll have to do a

    $folder = get-file-name WinXP

    New-VM-$folder file...

    Remove the line of New - VM WhatIf switch if you really want to start creating virtual machines.

Maybe you are looking for

  • I need service-firmware for Toshiba 32RL938G

    Hello I need auto firmare starting at the 32RL938G of Toshiba, the screen is black, green led. Do not start buttom...AutoStart for VL Series firmware does not... Please help me,Andrea.

  • Upgrade Windows and reactivate MS OneNote

    HelloI have a Satellite M30X.It starts only in safe mode. It will not even use last known good configuration.I think I'll wipe and start over.XP Home SP2 came to this topic, but I have an XP Pro SP2 volume license that I prefer to install.But I think

  • Download adobe flash player

    For some reason any when I download the latest version of the adobe flash player and it installs, it stops about 50-60% and a note appears and says that I have to close internet explorer program.when that I do, it still will not complete the installa

  • McAffee anti virus and MS WINDOWS 7

    Software anti-virus fill MS error STATING that I don't have McAffee when I do? I'm afraid to install windows security because I always get updates of McAffree but I can't manually activate the feature to analysis back? Suggestions for me please? Than

  • Deleting event calendar blackBerry Q10

    In the last 2 days I've been entering meetings in my calendar just to go back and they're all gone?  Any help would be appreciated.  Thank you, Sean