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?

Tags: VMware

Similar Questions

  • 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é

  • 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

    }}

    }

  • PowerCLI - there cmdlets to browse the store of data for files/directories and their creation?

    Hello

    PowerCLI - there cmdlets to browse the store of data for files/directories and their creation?

    If Yes, can you please let me know.

    I took a glance at the reference of the cmdlet, but can not find...


    Kind regards

    Dreamer

    You can use the data store provider.

    It is documented in the vSphere PowerCLI Administration Guide that was installed with PowerCLI.

  • Space in the store of data not released when a virtual machine is removed

    Hey all,.

    I have a game fairly simple up - two servers ESXi 2 Terminal servers. I'll have a problem, but with space in the store of data not be released on one of them after that I got a clone to the virtual machine, made my changes and removed the original. I can find no record anywhere, using vSphere (not in the inventory or when I browse the data store), but the HARD drive space using the server is still assigned somewhere.

    Any body have tips on where to find or how to fix this if it is indeed a problem?

    Any help is greatly appreciated.

    Thank you.

    How bout refreshing your data store? tab Configuration-> storage-> refresh?

    vcbMC - 1.0.6 Beta

    Lite vcbMC - 1.0.7

    http://www.no-x.org

  • VimApi find a store of data whith FindByDatastorePath failed?

    Hello

    I'll try to find a store of data on my ESX 3.5 server, there are 3 data warehouses:

    \[storage1\]

    \[storage2\]

    \[storage3\]

    I used the following c# code to find storage3,

    ManagedObjectReference _DataCenter = SvcConnection.Service.FindByInventoryPath (Indexderecherche, datacenter). ManagedObjectReference _DataStore = SvcConnection.Service.FindByDatastorePath (Indexderecherche, _DataCenter, the data store);

    _DataCenter is returned successfully.

    [When I fill out whith variable datastore 'storage3' it is a thrown Exception 'path of the invalid data store', so I tried to fill it whith "\[storage3\"] had so far all is fine but the ManagedobjectReference _DataStore is 'null '.

    What im doing wrong?

    THX, Christian

    I enclose you a script that illustrates retrieving the Mor I host datastore information hope this helps.

  • cannot find the folder "program data".

    original title: New Data - Program for Windows 7

    I just bought a new computer with windows 7.  I am trying to install programs, for example, installing a program to C:\program data\Quantum.  I go to 'my computer' and can not find the folder "program data".  Is it possible that windows is hide it?

    Sandy

    Hi Sandy

    The program data file replaced the all users in previous versions of Windows.

    Open Windows Explorer. Click on organize / folders and Search Options / View tab.

    Select the option Show hidden files, folders and drives, and then click apply/OK.

    Navigate to C:\Users. In this folder, you will see a folder named all users with a shortcut arrow or the layering of padlock. It is a symlink pointing to the ProgramData folder. Right-click on the folder and select properties to see this data.

    Your programs are not currently installed just for the ProgramData folder. This folder is used to allow any user (for all users) access to an installed program that allows any user to operate this program.

    Many times, when you install a program, you will see an option to install the program for the current user only, or to install for all users.

    Another way, you can see it is to click on the Start button, right-click on all programs, and select open all users. This will open Windows Explorer to the

    C:\ProgramData\Microsoft\Windows\Start Menu folder.

    Let us know if you have any other questions.

    Concerning

  • Is there a way to find the IP address associated with a device that is currently using my Apple ID?

    Hi, is it possible to find the IP address associated with a device that is currently using my Apple ID? There is a device currently using my Apple ID, and I would like to know its IP address. When I connect to appleid.com, the device is listed. The device is an iPhone. It is an emergency situation. Thank you.

    Unless it's on your local network, the IP address won't be useful to you in any way. (and no, you can do that)

    If this is really an "emergency", inform the authorities.

  • Is there a way to get the first Pro CS6 with still now I can't find the previous, offered versions with the subscription of the CC 2015?

    Is there a way to get the first Pro CS6 with still now I can't find the previous, offered versions with the subscription of the CC 2015? What is recommended for creating DVDs with interactive menus?

    Instructions again, cloud or version https://forums.adobe.com/thread/1992717 serial number
    -a of notes on different versions of cloud and step by step on these differences
    -contains information about the separate library download which is necessary
    -CS6 is the last reminder, see here #8 why http://forums.adobe.com/thread/1337952?tstart=0

    Still and 10 Windows https://forums.adobe.com/thread/2015461 use the compatibility mode of Windows 8
    problem/solution to install Encore CS6 https://forums.adobe.com/thread/1934087

  • Error: The lines of data with unmapped dimensions exist for period "1 April 2014".

    Expert Hi

    The below error when I click on the button Execute in order to load data in the area of data loading in 11.1.2.3 workspace. Actually, I already put in the tabs global mapping (add records of 12 months), mapping of Application (add records of 12 months) and map sources (add a month "1 April 2014' as the name of period with Type = Explicit mapping") in the service of the period mapping. What else should I check to fix this? Thank you.

    2014-04-29 06:10:35, 624 [AIF] INFO: beginning of the process FDMEE, process ID: 56
    2014-04-29 06:10:35, 625 [AIF] INFO: recording of the FDMEE level: 4
    2014-04-29 06:10:35, 625 [AIF] INFO: FDMEE log file: null\outbox\logs\AAES_56.log
    2014-04-29 06:10:35, 625 [AIF] INFO: user: admin
    2014-04-29 06:10:35, 625 [AIF] INFO: place: AAESLocation (Partitionkey:2)
    2014-04-29 06:10:35, 626 [AIF] INFO: period name: Apr 1, 2014 (period key: 4/1/14-12:00 AM)
    2014-04-29 06:10:35, 627 [AIF] INFO: category name: AAESGCM (category key: 2)
    2014-04-29 06:10:35, 627 [AIF] INFO: name rule: AAESDLR (rule ID:7)
    2014-04-29 06:10:37, 504 [AIF] INFO: Jython Version: 2.5.1 (Release_2_5_1:6813, September 26 2009, 13:47:54)
    [JRockit (R) Oracle (Oracle Corporation)]
    2014-04-29 06:10:37, 504 [AIF] INFO: Java platform: java1.6.0_37
    2014-04-29 06:10:39, 364 INFO [AIF]: - START IMPORT STEP -
    2014-04-29 06:10:45, 727 INFO [AIF]:
    Import of Source data for the period "1 April 2014".
    2014-04-29 06:10:45, 742 INFO [AIF]:
    Import data from Source for the book "ABC_LEDGER".
    2014-04-29 06:10:45, 765 INFO [AIF]: monetary data lines imported from Source: 12
    2014-04-29 06:10:45, 783 [AIF] INFO: Total of lines of data from the Source: 12
    2014-04-29 06:10:46, 270 INFO [AIF]:
    Map data for period "1 April 2014".
    2014-04-29 06:10:46, 277 [AIF] INFO:
    Treatment of the column mappings 'ACCOUNT '.
    2014-04-29 06:10:46, 280 INFO [AIF]: data rows updated EXPLICIT mapping rule: 12
    2014-04-29 06:10:46, 280 INFO [AIF]:
    Treatment of the "ENTITY" column mappings
    2014-04-29 06:10:46, 281 [AIF] INFO: rows of data updates to EXPLICIT mapping rule: 12
    2014-04-29 06:10:46, 281 [AIF] INFO:
    Treatment of the column mappings "UD1.
    2014-04-29 06:10:46, 282 [AIF] INFO: rows of data updates to EXPLICIT mapping rule: 12
    2014-04-29 06:10:46, 282 [AIF] INFO:
    Treatment of the column mappings "node2".
    2014-04-29 06:10:46, 283 [AIF] INFO: rows of data updates to EXPLICIT mapping rule: 12
    2014-04-29 06:10:46, 312 [AIF] INFO:
    Scene for period data "1 April 2014".
    2014-04-29 06:10:46, 315 [AIF] INFO: number of deleted lines of TDATAMAPSEG: 171
    2014-04-29 06:10:46, 321 [AIF] INFO: number of lines inserted in TDATAMAPSEG: 171
    2014-04-29 06:10:46, INFO 324 [AIF]: number of deleted lines of TDATAMAP_T: 171
    2014-04-29 06:10:46, 325 [AIF] INFO: number of deleted lines of TDATASEG: 12
    2014-04-29 06:10:46, 331 [AIF] INFO: number of lines inserted in TDATASEG: 12
    2014-04-29 06:10:46, 332 [AIF] INFO: number of deleted lines of TDATASEG_T: 12
    2014-04-29 06:10:46, 366 [AIF] INFO: - END IMPORT STEP -
    2014-04-29 06:10:46, 408 [AIF] INFO: - START NEXT STEP -
    2014-04-29 06:10:46, 462 [AIF] INFO:
    Validate the data maps for the period "1 April 2014".
    2014-04-29 06:10:46, 473 INFO [AIF]: data rows marked as invalid: 12
    2014-04-29 06:10:46, ERROR 473 [AIF]: error: the lines of data with unmapped dimensions exist for period "1 April 2014".
    2014-04-29 06:10:46, 476 [AIF] INFO: Total lines of data available for export to the target: 0
    2014-04-29 06:10:46, 478 FATAL [AIF]: error in CommMap.validateData
    Traceback (most recent call changed):
    Folder "< string >", line 2348 in validateData
    RuntimeError: [u "error: the lines of data with unmapped dimensions exist for period" 1 April 2014' ""]

    2014-04-29 06:10:46, 551 FATAL [AIF]: COMM error validating data
    2014-04-29 06:10:46, 556 INFO [AIF]: end process FDMEE, process ID: 56

    Thanks to all you guys

    This problem is solved after I maped all dimensions in order of loading the data. I traced only Entity, account, Custom1 and Custom2 at first because there is no source map Custom3, Custom4 and PIC. After doing the mapping for Custom3, Custom4 and PKI, the problem is resolved. This is why all dimensions should be mapped here.

  • How to find the last update date, time and user of the file field peoplecode

    How to find the last updated date time fields of peoplecode records?

    Thank you.

    We can check the update date-time using the following query

    SELECT LASTUPDDTTM IN THE PSPCMPROG WHERE OBJECTVALUE1 LIKE "RECNAME" AND OBJECTVALUE2 AS "FIELDNAME".

  • How to find the difference in date in years, months and days

    Hello
    I need to find the difference between 2 dates in the following way "years months days". "
    Please can help me, how can I achieve this.

    for example, in the scott schema emp table, I need to find the difference in date between sysdate and hiredate for an employee in the following way.

    12 years 7 months 4 days.

    Hello

    Please, see this post to AskTom [difference between 2 dates | http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:96012348060]. There is good information in this forum, for example you can also see this thread [calculation of years, months & days | http://forums.oracle.com/forums/thread.jspa?messageID=3115216�]

    Kind regards

    Published by: Walter Fernández on November 30, 2008 08:58 - adding another link

  • Create more free space in C drive

    Can I delete ~DF2831.tmp and similar files in the user/user/AppData/Local/Temp folder to create more free space in C drive?

    Rather than doing these cleanups manually, I suggest to you that use the built-in Disk Cleanup tool. Please see:

    http://windows.microsoft.com/en-US/windows-vista/Delete-files-using-Disk-Cleanup .

    Make sure that your backups are up to date before proceeding as a precaution.

  • Whenever I try to update my iPhone 6 for the ios10 it is said it is impossible and that an error occurred during the installation? I ' have enough free space, so I'm not real why he keeps now.

    Whenever I try to update my iPhone 6 for the ios10 it is said it is impossible and that an error occurred during the installation? I ' have enough free space, so I'm not real why he keeps now.

    Try to update via iTunes.

    See you soon,.

    GB

  • Where should I go on my computer to find the pie chart that shows how much space is used/left on my computer?

    Where should I go on my computer to find the pie chart that shows how much space is used/left on my computer... (my question is not related to the questions at the beginning).

    Open my computer, right-click the drive icon, select 'Properties' and you'll see the pie under the general tab.

    Jim

    Microsoft MVP - moderator of the Forum - consumer security live a care - Live Mesh - Microsoft Security Essentials

Maybe you are looking for