Automation

 View Only
  • 1.  Help newbie write a powerCLI script

    Posted Jun 20, 2015 01:59 AM

    Hi

    I want to set the config on all VM's that have a specific tag.

    Basically want to work through all the vm's on each host on each cluster at each site. check if the vm has a specific tag say "DOME" and then I want to set the latency sensitivity setting to high. I also want to set the resource schedule to high for CPU and say set the min value to 200 and also lock the vm entire memory.

    I have installed powerCLI v6, but have VC 5.5u2. just starting the upgrade process to V6

    Thanks

    Alex



  • 2.  RE: Help newbie write a powerCLI script
    Best Answer

    Posted Jun 22, 2015 06:06 PM

    It sets the CPU shares to high locks the memory, and sets the latency to high.  This assumes the tag category is 'DOME' and whichever tag that has that category will be associated with that VM

    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

    $spec.MemoryReservationLockedToMax = $true

    $spec.LatencySensitivity = New-Object VMware.Vim.LatencySensitivity

    $spec.LatencySensitivity.Level = [VMware.Vim.LatencySensitivitySensitivityLevel]::high

    Get-VM | where { ($_ | Get-TagAssignment -Category 'Dome') } | foreach {

    $vm = $_

    $vm | Get-VMResourceConfiguration | Set-VMResourceConfiguration -CpuSharesLevel High

    (Get-VM $vm).extensiondata.ReconfigVM_Task($spec)

    }

    What is the 200 reservation?  Do you mean the "MHz" reservation?

    I wish I could take full credit.  I saw past posts from LucD for setting some of these, I just combined them.



  • 3.  RE: Help newbie write a powerCLI script

    Posted Jun 24, 2015 11:26 AM

    $spec.LatencySensitivity.Level = [VMware.Vim.LatencySensitivitySensitivityLevel]::high



    Is there a way to list the particular levels of latency sensitivity level? How did you know that high was an option here for example





  • 4.  RE: Help newbie write a powerCLI script

    Posted Jun 24, 2015 03:29 PM

    LucD posted this for a similar question:  Re: Powercli for Latency Sensitivity?

    If you create these objects

    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

    $spec.LatencySensitivity = New-Object VMware.Vim.LatencySensitivity

    You can see the setting for the levels here:

    $spec.LatencySensitivity.Level = [VMware.Vim.LatencySensitivitySensitivityLevel]::high # right after the two colons, while you're typing, you should get an intellisense prompt for your options.  You probably need to make sure you're using an ISE, and not just the PS prompt.  I'm using PowerGUI.



  • 5.  RE: Help newbie write a powerCLI script

    Posted Jun 29, 2015 09:23 PM

    Hi

    One question, don't you have to read the extension data first and then set it to $spec. or do uninitialised values not flow through ?