Help with Script to add Hot CPU/Mem to large number of virtual machines

So I found these two functions of http://ict-freak.nl/2009/10/05/powercli-enabledisable-the-vm-hot-add-features/comment-page-1/#comment-14664

He

seems to be only for a unique virtual machine, but I need to set up

their making hundreds of multiple servers.  Is it possible to implement

foreach ($vm to $devVMs)

$devVMs = c:\listofvms.txt

in

the script to point to a list of virtual machines, such as a list of Windows 2008 64-bit

VMs, vms 32 bit Windows 2003 as another list etc. instead of making a virtual machine

at the same time.

The two functions are for features to add memory to warm and the VM OS per CPU.

Function Enable-MemHotAdd ($vm) {$vmview = Get - vm $vm |} Get-view$ vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec$ extra = New-Object VMware.Vim.optionvalue$ extra. Key = "MEM.hotadd" $extra. Value = "true" $vmConfigSpec.extraconfig += $extra$ vmview. ReconfigVM ($vmConfigSpec)}

Function Enable-vCpuHotAdd ($vm) {$vmview = Get - vm $vm |} Get-view$ vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec$ extra = New-Object VMware.Vim.optionvalue$ extra. Key = "vCPU.hotadd" $extra. Value = "true" $vmConfigSpec.extraconfig += $extra$ vmview. ReconfigVM ($vmConfigSpec)

}

Any help is greatly appreciated.

You can save this script in a .ps1 file.

After have connected you to the vCenter (Connect-VIServer), you run the script from the prompt PowerCLI.

.\myscript.ps1

It will read all the guestnames that you stored in the .txt file and for each of these calls to the function.

If you need to address another group of guests you modify the contents of the .txt file and run the script again.

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • Add Hot CPU does not work with 2012DC

    Hello

    I have a VM Win2012DC with CPU/Memory HotAdd enabled. This virtual machine has virtual material 9.

    When I add additional processors to this virtual machine, I see in Device Manager, the additional processors, but the system see only old 4 processors.

    I have scessfull add processors on server 2008R2, vmx-09 and 2012-server with vmx-08 and it works very well.

    Anyone have more information on this Bug?

    Falk

    Take a look at this

    VMware KB: A virtual machine for Windows Server 2012 does not recognize hot-add of virtual processors

  • HELP - how to get the number of virtual machines on a data store?

    Looking at the inventory of the data store in the VI client, there are a "number of Virtual Machines:" according to the General information for the Summary tab... I'm looking for a script that retrieves this information for me...

    I started the script but I'm stuck... I am very new on this...

    Get-Datastore. WHERE-object {$_ .name - like "wlp" ' "} #this gives me all the data which are not local warehouses

    Could someone give an overview on how to script to retrieve the number of virtual machines on data warehouses...

    Thank you, Lee

    Sorry, something went wrong with the copy - paste

    Get-Datastore | where {$_.Name -like "vmfs*"} | Sort-Object -Property Name | %{$_ | select @{N="DSname"; E={$_.Name}},
                                                                          @{N="VMcount";E={($_ | Get-VM | Measure-Object).count}}}
    
  • Number of virtual machines per cluster with New-VIProperty

    Hello

    I would like to get the number of virtual machines per cluster using New VIProperty like this:

    New-VIProperty - ObjectType VMHost-name NumberOfVMs'

    -The {($Args [0] |) value} Get - VM | Measure - Object). Count} '

    -Force

    Get-Cluster | Select Name, NumberOfVMs

    But I only get zeros.

    Can someone help me?

    Thank you

    Frédéric

    Take a look at my property NumberOfVms for Clusters.

  • While trying to see Planner installation and operation, the test in local mode, the EXECUTION fails with message "Waiting for the number of virtual machines to register.

    While trying to see installation and operation Planner, the test in local mode with only 1 VM the EXECUTION fails with message "Waiting for the number of virtual machines to register.

    There may be a lot of problems in the desktop VM. Agent service see Planner is not running in VM Office. You can check in the event viewer to see what kind of error occurs. The most usual error missing file IP.txt c; drive or harness IP in the IP.txt produce if there is.

  • 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 '.

  • Help with script to change the network name.

    Hello

    I made a small script to help me rename the label of network on a portgroup and then correct the label of network on all the virtual machines with this label.

    I came across the problem that it could not update on the virtual machines network label because the portgroup did not exist (this must be because it does not wait for the first order at the end?). I fixed that by doing a line with: "Start-Sleep-seconds 10.

    The script works, but I don't like the solution with 10 sec sleep because it could go wrong if the portgroup takes more than 10 seconds to create (unlikly).

    I tried different things, for example "Wait-task" but without success.

    any ideas?

    $esxi = Read-host "enter the IP address of the host."

    $portgroup_old = Read-host "Enter the name of the portgroup you wish to rename.

    $portgroup_new = Read-host "enter the new name of the portgroup.

    Get-VMHost-name $esxi | Get-VirtualPortGroup-name $portgroup_old | Game-VirtualPortGroup-name $portgroup_new

    Start-Sleep - seconds 10

    Get-VMHost-name $esxi | Get - VM | Get-NetworkAdapter | Where {$_.NetworkName - eq $portgroup_old} | Together-NetworkAdapter - NetworkName $portgroup_new - confirm: $false

    Unfortunately, with groups of standard port vSwitch, that's what you're stuck with.

    You could try a loop 'while' like this instead:

    Get-VMHost-name $esxi | Get-VirtualPortGroup-name $portgroup_old | Game-VirtualPortGroup-name $portgroup_new

    While (Get-VMHost-name $esxi |) Get - VM | Get-NetworkAdapter | Where {$_.NetworkName - eq $portgroup_old})

    {Get-VMHost-name $esxi |} Get - VM | Get-NetworkAdapter | Where {$_.NetworkName - eq $portgroup_old} | {Set-NetworkAdapter - NetworkName $portgroup_new - confirm: $false}

  • Help with script distributed switches Reporting

    Hello everyone, my name is Sebastian and I have a question for the VMware community.

    I need to know what network card physical and ESX are connected to a distributed switch. I've found that for Virtual Switch: Re: help with vSwitch reporting script. I would do the same thing with DvSwitch.

    Any idea?

    Thank you very much in advance for your help.

    Kind regards

    Sébastien.

    Take a look at 1. Re: get NIC host assigned to a dvSwitch  

  • Need help with script to find the virtual computer by IP

    Looking for a script that will correspond to the vm to IP, but should be able to find several IPS at the same time.

    I put this together from scripts on the net, which works well to search for a single IP address at a time:

    $match_address = Read-Host "enter the IP address to find."

    Get - VM | %{

    $vmips = $_. Guest.IPAddress

    {foreach ($ip in $vmips)

    If ($ip - as $match_address) {}

    "VM found correspondence address: {0}" f $_. Name

    }

    }

    }

    But would need to be able to enter several IP addresses of different subnets in the $match_address and search script for a match for every ip address.

    Could you please try this?

    function search-VMAssociatedToIP {}

    (param

    $ArrayOfIPToCheck

    )

    {in process

    $VMsAndAssociatedIP = get-view - viewtype 'virtualmachine ' | {foreach-object

    $VM = $_

    $_.guest.net | {foreach-object

    $Net = $_

    $_. IpAddress | {foreach-object

    $IpAddress = $_

    $Output = New-Object-Type PSObject-Prop ([ordered] @ {}

    "VM" = $VM. Name

    "NetworkName" = $Net.Network

    "IP address" = $IpAddress

    })

    Return $Output

    }

    }

    }

    $ArrayOfIPToCheck | {foreach-object

    $IPtoCheck = $_

    $VMsAndAssociatedIP | where {$_.} IpAddress - eq $IPtoCheck} | {foreach-object

    $Output = New-Object-Type PSObject-Prop ([ordered] @ {}

    "IpToCheck" = $IPtoCheck

    'VM' = $_. VM

    "NetworkName" = $_.NetworkName

    'IpAddress' = $_. IpAddress

    })

    Return $Output

    }

    }

    }

    }

    $MyArray = "10.0.33.1","10.0.30.11","10.0.20.11","10.0.32.1".

    Search for VMAssociatedToIP - ArrayOfIPToCheck $MyArray | OGV

    Use a table entry.

    First get the IP addresses of all computers installed correctly (only for virtual machines with VMware tools) virtual based on get - view so the collection will be fast.

    Then compare with the PPE provided as input.

  • Add NT user to the Group Admin Local (virtual machine in a field)

    Are there any custom script that we could write to add NT user a local administrator of a virtual computer that is in a domain as well? Any ideas? Thank you.

    In what context have you used it? This code example is part of a larger solution, with specific steps...

    in fact, the only command that must be executed is the net localgroup... order... the code a little older a workflow where I picked up the text in a reg temp file and then imported the reg file... the reg file create a runOnce registry who was apparently alone running if you connect to the new virtual machine until a first domain administrator - is not ideal... but using ONLY the command net localgroup in there that's what I found to work more consistently.

  • Script to change the name of the file to the virtual machine and its associated files

    Hello

    I'm looking for a script to change the name of the virtual machine in virtual center and also change it has associated file names in the data store to match file name of virtual machine. But the vmdk file will contain a descriptor which maps the - flat.vmdk file. So not sure that we can achieve this through a script.

    Thanks in advance!

    Not really as much as I know.

    The advantage of the svMotion is renamed it the files (.) VMX, VMDK,...) For you.

    The only alternative would be the command line. See Duncan Howto: renaming a virtual computer.

    With the help of the plink.exe tool which could possibly be scripted.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • VSphere number of virtual machines per CPU

    I've seen estimates of virtual machines per CPU and I understand that it depends on a combination of things. I think 4-5 virtual machines per CPU is up around. We run HP Proliant DL380 G5s (2 quad core) and it seems like that 4-5 per CPU core will be our number. Memory being the main factor limiting.

    I am now watching the servers (2 quad core) Proliant DL380 G6 and recital 72 GB of memory. Before I size like that, I want to know if the 8-10 mV by heart is conceivable. Even if I think that my current hardware could choke if I tried, I thought that perhaps most recent families of processor as the Proliant G6 Nehalem with VSphere improvements with regard to the planning of the CPU that could be a possibility.

    Also, I assumed variess speed processor directly with the virtual machine by core equip. As CPU speed increses # or virtual machines by increases in Basic. Is this correct?

    You're right it depends on many things, but for the general basic rules 4 - 6 virtual machines by heart for ESX 3.x and you can run no risk 6 to 8 virtual machines to vSphere, if you know that your virtual machines are use of the lamp, then pushing to 6-10VMs might do, but you should perhaps follow the activities and decrease if resources are hammering.  vSphere certainly has better CPU planning services and get the best performance from predecessor.  I test it on a test environment and the maximum stress and see how it runs.  What types of workloads and servers do you think?

    If you found this information useful, please consider awarding points to 'Correct' or 'useful '. Thank you!!!

    Kind regards

    Stefan Nguyen

    VMware vExpert 2009

    iGeek Systems Inc.

    VMware, Citrix, Microsoft Consultant

  • Script in VMWare Server to stop, save and reboot the virtual machine

    Hello!

    I want to create a script from windows vista Pro (which is my vmware server host) this judgment of a virtual machine before you save it and restart the virtual machine after.

    Does anyone know how to do this? This is my first script, so I don't know how to start...

    I saw this link:

    http://www.Petri.co.il/virtual_script_startup_shutdown_vmware_servers.htm

    But it seems to be for VMware Server 1.X because I can't found the vmware-cmd in the server vmware 2.0 folder.

    Thanks for your help!

    I don't know if you are receving notifications to your PMs, just I have sent you a PM >

  • Add physical disk to disk attached in ESXi virtual machine

    Hi friends,

    I would have attached physical disk to the virtual machine, I explain:

    I have a freenas VM create in ESXi 5.5 but I want to add a new hard drive, this hard drive is a physical, fixed equipment in my 5.5 ESXi, possible? If Yes, how?

    After I want to mount iSCSI in freenas and I'll make backups

    Thank you very much

    Rapici

    Hi brunofernandez1

    very thanks for the doc, I'll try Raw Device Mapping and explain

    Thank you very much

    Rapici

  • script to summarize the use of the total disc of virtual machines

    How can I summarize sizes total vmdk (not thin) of a list of virtual machines in vc?

    Hello, once again-

    I see your second post.  Yes, you could go that route, too.  You are close to, simply add in a Measure-Object call.  A little cleaned up, it would be like:

    $machines = Get-Content c:\servers.txtGet-VM -Name $machines | Get-HardDisk | `    select @{N="VMName";E={$_.Parent.Name}},@{N="Capacity(GB)";E={[math]::truncate($_.CapacityKB / 1MB)}},Filename | `    Measure-Object -Property "Capacity(GB)" -Sum
    

    How does do for you?

Maybe you are looking for

  • Hasselblad H5D - 50 ° c

    I recently received a Hasselblad digital back (Hasselblad H5D - 50 ° c). And while this return is listed as a camera compatible and must be supported from digital camera Raw Compatibility Update 6.04, .fff files leads to constant of the two crashes t

  • LoadKey failed with error 1117 (STHIVE #0)

    OK, so when I turn on my PC, it looks like it is loading up... then it goes to a page "Loading Windows files", then an error pops up: "LoadKey failed with error 1117 (STHIVE #0). Then I press ok that error box, so now he takes me to the "Startup Repa

  • Vista Windows - security

    my internet explore opens at random, even if I set Google chrome as my default browser.  I sometimes play music, but no Web page showing.  Windows Defender does not open, it flashes on the screen and I can see a severe upper level alert, but disappea

  • Manual for Dell place 8 Pro 750-LT. Stylus?

    So I just got the 'new' pen and it works fine. It seems that all the bugs people are complaining were crushed. However, it might work even better if it had some actual instructions. I searched and returned empty. Any ideas?

  • Hi, my pc doesn't let me install any games and more.

    Initially, it would be fair to Setup.exe has stopped working, sometimes it still is, but other times it loads well, splash screen appears, small loading bar appears and after reloading, nothing happens and it disseapears. Tried to install Star Wars K