Deployment of a virtual machine from a store of data with less space, but enough for the virtual machine

I received this delicate task, and I can understand not just how to replace all parts.

I need to create a script that will be smartly decided what data store to deploy a virtual computer.  We do not want to deploy in a data store that has the most space, we want to deploy to the data store that has the least space but can still account for the space for the (vm + 5%) and still leave 50 GB free on the lun after the move.

Thus, for example, if the virtual machine is 40 GB, we want the script to select the data store that has a close to 90 GB available without being under.

So my thought for this approach is:

  • Create the query to get all the relevant LUNS.  This excludes all the LUNS with the 'local' name in it and excludes all LUN owners (who have a slightly different naming convention then our general shared storage LUNS)
    • This piece, which I partially understood
      • Get-datastore. WHERE-object {($_.)} Name: corresponds to "PAR0 [1-4] _ [edp] * disk *")- and ($_.) "." Name - notmatch 'local')}
    • Now, I need to get all of their total size and free space.  Perhaps export this list to a CSV, however if I have to.
    • Create a variable that contains: the size of the total virtual machine to the virtual machine that is deployed before its deployment.
    • Deduct vm size against each data store size and pull in some way that that also close to 50 GB free on the data store and still facilitates the deployment of the vm.

I have a few other scripts, I scrounged on the internet that I tried to restore... but I just don't calm not having all the pieces...

  • Get-Datastore. Where-Object {$_.} ParentFolder-match 'Internal'} ' | Select-Object - property data center, FreeSpaceMB, CapacityMB name, ' | Tri-objet-property FreeSpaceMB
  • Select-Object Name,@{n="CapacityGB";e={[math]::round (($_.)) {{(CapacityMB/1024))}}, @{n = "FreeSpaceGB"; e = {[math]: round (($_.))}} {{(FreeSpaceMB/1024))}}, @{n = "FreeSpacePercent"; e = {[math]: round (($_.))}} FreeSpaceMB / $_. {{(CapacityMB*100))}} | Sort-Object FreeSpaceGB

Any help would be greatly appreciated!

-Knotz

Try something like this

# Get all data warehouses

$ds = get-Datastore. Where-Object {($_.)} Name: corresponds to "PAR0 [1-4] _ [edp] * disk *")- and ($_.) "." Name - notmatch 'local')} |

Select-Object Name,

@{n = "CapacityGB"; e = {[math]: round (($_.))}} {{(CapacityMB/1024))}}.

@{n = "FreeSpaceGB"; e = {[math]: round (($_.))}} {{(FreeSpaceMB/1024))}}.

@{n = "FreeSpacePercent"; e = {[math]: round (($_.))}} FreeSpaceMB / $_. {{(CapacityMB*100))}}

{foreach ($vm in Get - VM)

# Find possible candidates

$candidates = $ds | where {($_.)} FreeSpaceGB - $vm. (UsedSpaceGB-50) - gt 0}

# Find the best candidate

$target = $candidates | Tri-objet-property FreeSpaceGB-descending | Select - 1 first

Write-Output "VM $($vm.). Name) can go to $($target.) (Name) ".

}

Tags: VMware

Similar Questions

  • Download the virtual machine in a store of data with powercli

    Hello

    How to list the files of virtual machine on a store of data with PowerCLI

    I have a virtual machine and I want to see all the files in a data store (such as hard,.-flst.vmdk, .log, .nvram) using powercli. Is this possible?

    TKS.

    Try the following, it uses a function of my position of friendly units .

    Function Get-FriendlyUnit {}

    <>

    . Numbers converted small binary multiples SYNOPSIS

    . DESCRIPTION the function accepts a value and him will convert

    in the largest available binary unit.

    . Author NOTES: Luc relaxing

    . Value of the PARAMETER

    The value to convert.

    This number must be positive.

    . IEC PARAMETER

    A switch to indicate whether the function should return the CIS

    Unit, or the names of the units most commonly used names.

    The default is to use the commonly used unit names.

    . EXAMPLE OF

    PS > Get-FriendlyUnit-value 123456

    . EXAMPLE OF

    PS > 123456 | Get-FriendlyUnit - CIS

    . EXAMPLE OF

    PS > Get-FriendlyUnit-value 123456,789123, 45678

    #>

    (param

    [CmdletBinding()]

    [parameter (mandatory = $true, ValueFromPipeline = $true)]

    [double []] $Value,.

    [switch] $IEC

    )

    Begin {}

    $OldUnits = "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB".

    $IecUnits = 'B', 'KiB', 'MiB', "GiB", "TiB", "PIF", "BANK", "ZiB", "YiB".

    If ($IEC) {$units = $IecUnits} else {$units = $OldUnits}

    }

    {in process

    $Value | %{

    If ($_ - lt 0) {}

    Write-Error "Numbers must be positive."

    breaking

    }

    If ($value - gt 0) {}

    $modifier = [math]: Floor([Math]::Log($_,1KB)))

    }

    else {}

    $modifier = 0

    }

    New-object PSObject-property @ {}

    Value = $_ / [math]: Pow(1KB,$modifier)

    Unit = & {if ($modifier - lt $units. {Count) {$units [$modifier]} else {'1KO E {0}' f $modifier}}

    }

    }

    }

    }

    foreach ($vm in (Get-View - ViewType VirtualMachine - property Name, 'LayoutEx.File')) {}

    $vm. LayoutEx.File |

    Select @{N = "VM"; E = {$vm. Name}},

    @{N = 'Name'; E={$_. Name.Split(' ') [1]. "Split('/') [1]}},"

    @{N = "Path"; E={$_. Name}},

    @{N = 'FileType'; E={$_. Type}},

    @{N = "Datastore"; E={$_. Name.Split(']') [0]. TrimStart('[')}},

    @{N = "size"; E = {}

    $val = get-FriendlyUnit-value of $_. Size

    "{0:n2} {1}" f $val. Value, $val. Unit

    }}

    }

  • Find the store of data with more free space.

    So I'm trying to build a script to configure the virtual machine.

    I'll have it retrieve the node to keep newly available vm out based on the cluster, I said to use. I'm just using the Random function to do that then I select a node in the cluster.

    Where I have questions, how can I

    find the data store less used, based on a particular data store naming scheme.

    I want to say is:

    Hypathetically, I for example named data warehouses:

    store data-prod-01 200 GB free

    store data-prod-02 500 GB free

    free data-prod-03 10 GB store

    free data-qa-01 200 GB store

    free data-qa-02 1000 GB store

    I want to throw in a piece of code to tell him to watch data warehouses "datastore-prod *" and place the virtual machine on the store of data with the most space. (that's assuming that the vm will agree on the DS and let fresh generals)

    I guess I want to know if it is possible?

    I would also be concerned about scenario that perhaps the vm should I build just will not match on any of my other data store. I guess I need a logic to check if it is still possible.

    This is more than a wish rather than a necessity. I'm thinking if I just read the info, or use a cvs file after running the script. Any recommendations would be greatly appreacted.

    Hello, drivera01-

    You should be able to do this with a very small amount of code.  Download all data warehouses that correspond to the model name, sort free space (in descending order) and select the top one.  As:

    ## get the datastore matching datastore-prod* that has the most freespace$oDatastoreWithMostFree = Get-Datastore datastore-prod* | Sort-Object -Property FreespaceGB -Descending:$true | Select-Object -First 1
    
    ## if the freespace plus a bit of buffer space is greater than the size needed for the new VMif (($oDatastoreWithMostFree.FreespaceGB + 20) -gt $intNewVMDiskSize) {<# do the provisioning to this datastore #>}else {"oh, no -- not enough freespace on datastore '$($oDatastoreWithMostFree.Name)' to provision new VM"}
    

    The second part, where it checks for sufficient freespace on the data store that has the most free, can be updated to behave as you need, but that should be the basis.  How does this look?

  • How to remove a store of data with force

    Last week we did a migration of old data spinning again spinning. After in the opposite direction of all the virtual machines to the new file server, we made all virtual machines online since the new file server. Now the thing is, I can't delete the existing data store (old spin). When I tried to delete the VC data store, it throws an error:

    error.JPG

    Y at - it a command/tip to remove the store of data with force?

    Storage.JPG

    Thank you

    Ganesh

    See this thread:

    http://communities.VMware.com/thread/89271

    André

  • I am not able to download apps for my iPhone on the App Store. He just 'waiting '. But never starts the download. I tried with wifi and mobile data. The two are not download apps

    I am not able to download apps for my iPhone on the App Store. He just 'waiting '. But never starts the download. I tried with wifi and mobile data. The two are not downloading the applications Can u find out what's wrong? I use iPhone 5s

    I had the same problem. At the same time hold the screen lock button and the home button until your iPhone restarts. That solved the problem for me.

  • How to get outlook on my surface? can I download? Buy it in the store? It is already loaded? Thanks for the tips

    How to get outlook on my surface? can I download? Buy it in the store?  It is already loaded? Thanks for the tips. John Harney

    With Windows RT, you need to install apps on the Store Windows and Outlook isn't here right now. Microsoft has created versions of Word, Excel, PowerPoint and OneNote for the ARM in Surface RT processor, but I have not heard of the future prospects for Windows RT.

    Kate

  • Best way to migrate data from a store of data to a ROW

    Hi all

    I have a maybe simple question.

    I have some SQL clusters to customers that are not configured by the best practices of VMware.

    They are running ESX 4.0 with vCenter 5.0 u2 u2

    Some of them are running two nodes on the same ESX, some of them have mixtures of RDM and data warehouses and LUNS are connected by mixtures of policies of multiple paths.

    I can make changes to the MPP and the separation of the knots without problem, but I was wondering if anyone has recommendations for the data transfer of any store of data that exists in a ROW?

    Obviously if it is possible I would disconnect the data store, add as a RDM again but is it ok to do?

    Are there catches hidden here?

    If this possible isn´t would I need to create a new drive as a vMotion RDM and the storage of the data between the 2?

    I Don t need to migrate data for the operating system, the data on disks, so I can use storage vMotion for this or it would be better to run VMware converter?

    Someone at - it advice or recommendations?

    Thanks in advance

    Mark

    Obviously if it is possible I would disconnect the data store, add as a RDM again but is it ok to do?

    Are there catches hidden here?

    If this possible isn´t would I need to create a new drive as a vMotion RDM and the storage of the data between the 2?

    I Don t need to migrate data for the operating system, the data on disks, so I can use storage vMotion for this or it would be better to run VMware converter?

    Someone at - it advice or recommendations?

    Thanks in advance

    Mark

    You can't add the data store to a server asa RDM because the data store is in VMFS format.

    you could use vmware converter or restore backups to place the data on the rdm.

  • How can I register all of the VMX files found in a list of stores of data with new names

    Hello-

    I'm trying to find a way to search through a given list of data and each discover a warehouse. VMX file, add this machine in the inventory I want to prepend the name of the machine as something different. That is to say, instead of "Machine1", I wish it were registetred as "auto-Computer1.  So, imagine I have an empty data center with 4 warehouses of data stored in a table $arrDatastoreToInclude.  I want to loop through each of these data stores and add all the VMX files I found back in the inventory.

    I know that I can use the following to get data warehouses I want:

    $dsindatacenter = get-data center $DataCenterName | Get-Datastore? | {$arrDatastoreToInclude - contains $_.} Name}

    But I have no idea how to analyze these data stores for the VMX files and what command to add them in the inventory.  Can anyone help?

    Try the following, it is based on the script of the position that Robert mentioned.

    You will need to provide a file (in $VMFolder) where unregistered virtual machines will be stored.

    The Set-VM cmdlet will take care of the rename.

    $DatacenterName = "MyDatacenter" $arrDatastoreToInclude = "DS1","DS2","DS3","DS4"
    
    $dc = Get-DataCenter $DataCenterName $dsindatacenter =  Get-Datastore -Datacenter $dc | ?{$arrDatastoreToInclude -contains $_.Name}
    
    $VMFolder = "MyFolder"
    $ESXHost = Get-VMHost -Location $dc | select -First 1
    foreach($Datastore in $dsindatacenter) {
        # Collect .vmx paths of registered VMs on the datastore     $registered = @{}
        Get-VM -Datastore $Datastore | %{$_.Extensiondata.LayoutEx.File | where {$_.Name -like "*.vmx"} | %{$registered.Add($_.Name,$true)}}
    
       # Set up Search for .VMX Files in Datastore    New-PSDrive -Name TgtDS -Location $Datastore -PSProvider VimDatastore -Root '\' | Out-Null    $unregistered = @(Get-ChildItem -Path TgtDS: -Recurse |         where {$_.FolderPath -notmatch ".snapshot" -and $_.Name -like "*.vmx" -and !$registered.ContainsKey($_.Name)})
        Remove-PSDrive -Name TgtDS
       #Register all .vmx Files as VMs on the datastore   foreach($VMXFile in $unregistered) {
            New-VM -VMFilePath $VMXFile.DatastoreFullPath -VMHost $ESXHost -Location $VMFolder |
            Set-VM -Name ("Auto-" + $_.Name)
       }
    }
    

    Unregistered virtual machines will be saved with Displayname that is present in the VMX file.

    If this would cause a conflict with VM already registered, you can use the Name of the cmdlet New-VM parameter

  • How to create a store of data with the small block size

    Hello

    I want to create a data store on two 160 GB drives. All the VI Client allows me to do is to create a data store of whole disc with 1 MB block. But for reasons of performance with the virtualized Oracle RAC, which is 8K organized, I want to go down to a smaller block size. But how?

    Is it possible to split my drive to (lets say) four parts, each with a smaller block size and putting them all together like extends in a data store? To create partitions with fdisk does not work, as the VI Client wants to use the unpartitioned disk. Any ideas?

    Robert

    Hello

    It is not possible. The smallest block size is 1 MB on a VMFS partition.

    Best regards

    Lars Liljeroth

    -

  • upgrade from windows mobile 5.0 to windows mobile 6.0 for the palm treo 750v

    Hi Sir,

    Thanks for your advice.

    I managed to solve the problems of blocking Windows mobile 5.0 in palm treo 750v.

    Moreover, may I know how upgrade from windows mobile 5.0 to windows mobile 6.0?

    I downloaded the program below, but I have try several times still cannot.

    Please give some advice...

    Thank you...

    treo750_2_23_row_en_desktopupdater

    Hello and welcome to the forums. I replied to this on the tail of your previous post, but re-post here for you:

    If your phone is branded AT & T, then the treo750_2_23_row_en_desktopupdater is not the correct download for your phone. the best upgrades for your phone would be on support for the 750 ATT page, found here:

    http://KB.Palm.com/wps/portal/KB/na/Treo/750/att/home/page_en.html

    There you can find updates, patches, accessories and manual user for your phone.

    I hope this helps!

  • display data from a store of data failefk because no relevant context?

    Here are the steps in the creation of model "test".
    1. definition tab
    Name = test
    = Oracle technology
    Logical schema = dbinfo

    2 reverse tab
    Standard
    Context = BITEST

    3. selective tab reversed
    Selection of table A

    4 and then clicking on the button "Reverse"-> "apply"-> "OK".

    5 data store "A" shown in the model 'test', but when I right click and select "Show data", there was an error skipped,
    there is no connection for this pair of schema logic/context: dbinfo / S_CONTEXT_CHECKBAK
    if I add the logical schema 'dbinfo' and the physical schema corresponding to the context "S_CONTEXT_CHECKBAK". "Look at the data" can work well.

    It is really strange that context "S_CONTEXT_CHECKBAK" is a context totally dependent on this definition of 'test' of the model, then why I have to use here? And this is not the default context.

    Any comments will be appreciated!


    Best wishes
    Satine

    In the designer,.
    As for help, context Menu, you have a list box, choose the right context here.

    When you try to view your data, if I remember correctly, it uses that filled here.

    Kind regards

    Brice

  • How keep the paths with LV, I am looking for the way to store paths?

    I'm looking for ways to store paths, so that when I run a VI requiring this way, I don't have to set it.

    What I want is to establish once > store it > open a VI who select automatically.

    I have an example, but it gives a bad result.

    One thing to think creates a configuration file that contains constant file paths that you need.  I think it's a bad idea to have hard coded paths in your code.

  • Received the call from someone claiming to be with Microsoft asking to pay for an upgrade

    and press END and then entered Microsoft View and request if there are errors. Said that I have to pay for an upgrade to my computer or my hard drive will crash.   IS this CORRECT are of yourselves or a scam.  They asked for money to upgrade.

    * original title - I had a phone call today from a person who had the bad English who said he was from London. He said represented Microsoft and asked me to press the sign of Windows on my laptop *.

    Scam. Read the sticky at the top of the Windows forum.

  • CHKDSK from every time I turn on my computer, but stalled before the end

    Why CHKDSK is from whenever I turn on my computer, and why is it at the point dead 46% in the process?  I guess that a better question is what can I do to prevent this?

    Why CHKDSK is from whenever I turn on my computer, and why is it at the point dead 46% in the process?  I guess that a better question is what can I do to prevent this?

    Hello


    How does the CHKDSK begins? Do you want to say that it begins after you log in to Windows? This happens in fashion as well safe? If she starts after you open a session and is not a Mode safe then please, try the following
    [1] method: Set up the commissioning of the elements by using the utility Configuration of Microsoft
    • On the start menu, insert the following text and press ENTER: msconfig
    • On the Startup tab, uncheck the unrecognized elements
    • Click OK to save the changes
    Thank you
    I hope this helps :)
  • Someone at - it a flowchart from end to end (or some sort of page document) for the Page of Google-&gt; Eloqua - Salesforce destination?

    We are testing Google AdWords landing pages, include Google Code SFDC, and I was not able to visualize the complete flow of information between the Eloqua and SFDC launch page. If anyone has experience with this integration, I'd love to hear from you.

    Hi Tom,

    I presume that by Google for code SFDC, you are referring to the javascript sfga.js that feeds on Google Adwords information in Salesforce.  If Yes, then the integration between Eloqua, Salesforce and Google requires 2 forms: Eloqua form and a web Salesforce to run the form.  The imformation flow is as follows:

    When the sfga.js javascript is added to a form of the landing page, it changes the action of the form parameter to publish your form data on a managed server from Google Analytics, who will then report data to your original form target. in this case, Eloqua.  When the bid hits your form Eloqua, Eloqua will execute any form of processing steps and then should republish your data to your Salesforce web to lead form using the data of publication in server processing step.  If you want to avoid creating duplicate in Salesforce leads, you can make this conditional on a database search aseo so that it will run only if the contact who sent the form does not have an ID of lead.  When the form data are displayed to Salesforce, a new track is created.  About 15 minutes after the presentation, the scripts of Google will sync with Salesforce and check for recently created conduit that the information corresponds to the data submitted by the form; If there is, the fields of lead sources are updated.  I hope it's useful.

    Ryan Wheler

    Product specialist

    Eloqua

Maybe you are looking for

  • Crashes and return 20.0.1 to 20.0 for no reason

    I had a lot of problems with Firefox crashing. Can I get a dialog box that appears and says that windows must be restarted to complete a previous installation or something like that. She also continues to go back to 20.0 after I installed 20.0.1 5 ti

  • Laptop: cannot hear any sound from my computer

    My sound does not work in Windows 10. No sound at all from YouTube videos, music and media players, Windows system sounds, etc.

  • How to recharge the iPhone

    Hey, just a quick question. I got my iPhone 6 a few days ago, so it's brand new and it's amazing! But should I just it load when less than 20% or just whene I want? and also should I I let down completely and then the load completely (like I should o

  • Freezing of funds

    Hi my name is Danny. I have a desktop computer running windows xp home edition and intel pentium D with card mother foxcom. My problem started about 7 weeks ago with my pc is freez anything. I ran the scan disk and Defrag virus scan many many times w

  • How to find serial USB port assignments programmatically?

    I use a system of 64-bit Windows 7 for hobby hardware / software development.  I am writing a script that controls 3 separate boards via a serial port USB microcontroller.  Unfortunately, I find that the COM port assignments are very dynamic, sometim