Command to show total remaining storage space for a host

I'm looking for a way to easily view the total amount of remaining storage space for a virtual host. At present, viewing the properties for a host in SCVMM is the only way to view this in the GUI. I was looking at sourcing a Powershell command to do this, and
then feed it into a custom column, for easy viewing within the VMM main window. Has anyone desired for such a thing?
Many thanks.

Hi!
Since I find your question to be interesting, I decided to write two scripts that might be of use to the both of us, and the community, perhaps. The first script does what you wanted. As a bonus, I wrote a similar script that checks for free space on the
virtual machines.
IMPORTANT: I tested the scripts on SCVMM 2012 Service Pack 1. I do not recommend running the scripts without checking for possible compatibility issues.
You can use the scripts in several ways. For example, you could run the scripts every time before running SCVMM. Or you could create a Scheduled Task using a Group Managed Service Account. Or on wednesdays...
The scripts update the fields when ran.
Prerequisites for running the first script:
Execution Policy, of course
Custom Property: "Available Storage"
Here is the script you are looking for.
Import-Module virtualmachinemanager
$hostNames = (Get-SCVMHost | Select-Object Name).Name
$availableStorageProperty = Get-SCCustomProperty -Name "Available Storage"
ForEach ($hostName in $hostNames) {
$VM_Host = Get-SCVMHost -ComputerName $hostName
$availableStorage = $null
$availableStorage = $VM_Host.AvailableStorageCapacity / 1GB
If ($availableStorage) {
$availableStorage = $availableStorage.ToString("N") + " GB"
} Else {
$availableStorage = "N/A"
Set-SCCustomPropertyValue -CustomProperty $availableStorageProperty -InputObject $VM_Host -Value $availableStorage
In my organization, most of the virtual machines use only one disk, but 20% or more of all our virtual machines have two or three disks. That is why the second script checks free space on three disks per machine.
Of course, it is fairly easy to remove the lines where the script checks the state of the other two disks.
NOTE: If a Virtual Machine is in an unknown state (deleted configuration or missing in other way), the script returns several errors (six) for that machine. The script is not destructive in any way, it only updates the desired fields (Custom
Properties).
Prerequisites for running the script:
Execution Policy, of course
Custom Property: "Disk0 FreeSpace"
Custom Property: "Disk1 FreeSpace"
Custom Property: "Disk2 FreeSpace"
Here is the second script.
Import-Module virtualmachinemanager
Function Get-FreeSpace {
param ($disk)
If ($disk) {
$disk_freeSpace = $disk.MaximumSize - $disk.Size
$disk_freeSpace = $disk_freeSpace / 1GB
$disk_freeSpace = $disk_freeSpace.ToString("N") + " GB"
} Else {
$disk_freeSpace = "N/A"
Return $disk_freeSpace
$VM_Names = (Get-SCVirtualMachine | Select-Object Name).Name
$VM_disk0_freeSpaceProperty = Get-SCCustomProperty -Name "Disk0 FreeSpace"
$VM_disk1_freeSpaceProperty = Get-SCCustomProperty -Name "Disk1 FreeSpace"
$VM_disk2_freeSpaceProperty = Get-SCCustomProperty -Name "Disk2 FreeSpace"
ForEach ($VM_Name in $VM_Names) {
$VM = Get-SCVirtualMachine -Name $VM_Name
$disk0 = $disk1 = $disk2 = $null
$disk0 = Get-SCVirtualHardDisk -VM $VM | Select-Object -First 1
$disk1 = Get-SCVirtualHardDisk -VM $VM | Select-Object -Skip 1 -First 1
$disk2 = Get-SCVirtualHardDisk -VM $VM | Select-Object -Skip 2 -First 1
$VM_disk0_freeSpaceValue = Get-FreeSpace $disk0
$VM_disk1_freeSpaceValue = Get-FreeSpace $disk1
$VM_disk2_freeSpaceValue = Get-FreeSpace $disk2
Set-SCCustomPropertyValue -CustomProperty $VM_disk0_freeSpaceProperty -InputObject $VM -Value $VM_disk0_freeSpaceValue
Set-SCCustomPropertyValue -CustomProperty $VM_disk1_freeSpaceProperty -InputObject $VM -Value $VM_disk1_freeSpaceValue
Set-SCCustomPropertyValue -CustomProperty $VM_disk2_freeSpaceProperty -InputObject $VM -Value $VM_disk2_freeSpaceValue
If you have any questions, ask. I'll check in later.
Cheers!

Similar Messages

  • Custom column to show total remaining storage space for a host

    I'm looking for a way to easily view the total amount of remaining storage space for a virtual host. At present, viewing the properties for a host in VMM is the only way to view this in the GUI. I was looking at sourcing a Powershell command to do this,
    and then feed it into a custom column, for easy viewing within the VMM main window. This is probably best suited to the Powershell forums, but I placed the post here, as I may have overlooked another way to achieve this within VMM itself. Has anyone desired
    for such a thing?
    Many thanks.

    I'm looking for a way to easily view the total amount of remaining storage space for a virtual host. At present, viewing the properties for a host in VMM is the only way to view this in the GUI. I was looking at sourcing a Powershell command to do this,
    and then feed it into a custom column, for easy viewing within the VMM main window. This is probably best suited to the Powershell forums, but I placed the post here, as I may have overlooked another way to achieve this within VMM itself. Has anyone desired
    for such a thing?
    Many thanks.

  • I deleted all downloaded songs from my iphone but under Settings/About it still shows songs on my phone. How do I fix this?  I need to use that storage space for other things.

    I deleted all downloaded songs from my iPhone but under
    Settings/About it still shows songs on my phone.
    How do I fix this?  I need to use that storage space for other things.

    First thing to try is to reset your device. Press and hold the Home and Sleep buttons simultaneously ignoring the red slider should one appear until the Apple logo appears. Let go of the buttons and let the device restart. See if that fixes your problem.

  • Just purchased more storage space for iphone6 but not showing?

    I just purchased more storage space for my iphone6, 20gb, but my backup storage still shows 5gb?  How do I troubleshoot this problem, my credit card info is accurate?

    You cannot install more storage space on an iDevice. If you don't have space on the device to download to it, then you need to delete stuff from it. Buying more cloud space does not do a thing for you unless you store to the cloud and remove from the device.

  • HT5225 is moving to iCloud free: my iPhone is showing a 20GB storage plan for $40 a year?

    is moving to iCloud free: my iPhone is showing a 20GB storage plan for $40 a year?

    yes it free, you get 20 gb  as bonus

  • Storage space for sub mail accounts

    Does anyone know how I can allocate more storage space for my additional mail accounts? I ran out of space and purchased another 2gb of storage on my .mac account. However, none of this space is allocated to my additional mail accounts i.e. all of it goes into my main mail account (where I dont need it...). Any advice?

    This forum is for discussing issues related to the Mail & Address Book applications included with Mac OS X 10.4 (Tiger). Yours appears to be a .Mac issue that has absolutely nothing to do with Mac OS X’s Mail. The right forum for such questions would be one of the .Mac Forums, such as .Mac General, for example.

  • I want to cancel the plan storage space for any icloud Alstraetha

    How canceled storage space for any iClaoud

    Go to Settings > iCloud > Storage & Backup > Change Storage Plan

  • Why do we not receive 5 gb of free cloud storage space for the multiple Apple devices my wife and I have purchased?

    Why do we not receive 5 gb of free cloud storage space for the multiple Apple devices my wife and I have purchased?  Seems only fair.

    logical. fair. I can understand the confusion in policy  as another fine cloud service - DropBox - has a different model for increases in free storage amounts for one account = evangelism. As many policies as there are services probably.
    cya 'round o' kilted one
    CCC

  • How do I manage (i.e., limit) storage space for Messages?

    How can the amount of storage space for Messages be limited and/or managed? Messages are currently taking up nearly 600MB of my iPhone and iPad devices storage space. Deleting old message threads does not appear to reduce it. And I don't consider myself to use messages excessively.

    How can the amount of storage space for Messages be limited and/or managed? Messages are currently taking up nearly 600MB of my iPhone and iPad devices storage space. Deleting old message threads does not appear to reduce it. And I don't consider myself to use messages excessively.

  • HT204053 I have multiple apple devices, 2x phones ipad etc, but all are through the same email and I only get the storage space for one device, what should I do?

    I have multiple devices all under the same id and email but I don't get multiple icloud storage space and it's running out!
    Can anyone help as I've just bought an iphone for my daughter and would like to link it as well.
    Thanks in anticipation of your help.

    One icloud account gets a 5 GB of storage, regardless of the number of devices connecting to it.  But you're in luck, you can buy more storage for the account if you are running low.
    As for your daughter, be sure to get her own icloud account, otherwise she'll end up getting all your email, contacts, etc.  And if she deletes any of this data, it will be deleted on your devices as well.  Note:  you can all keep using the same ID for the itunes store for sharing purchased items.
    To create a new icloud account, go to
    http://www.apple.com/icloud/setup/

  • Icloud storage space for Mac book

    Will I get any extra icloud storage space , when I buy mac book pro. I am already using iPhone and ipad, so my 5GB icloud storage is almost finished. I know creating one more icloud I'd can give 5GB more , but I don't want too much ID and password.

    The 5GB is tied to the account, not the devices using it, so no matter how many devices you have logged into it you still only have 5GB free for the one account. As said, you can purchase more: additional 10GB, $20 p.a., 20 GB, $40 p.a., 50GB $100 p.a.

  • Do I need to partition storage space for windows 7 software?

    I'm still debating if I should sell my Alienware and buy a MB Pro Ret and my main questions is concerning storage space.
    I know that MBP can't compare to an Alienware gaming system but I hardly have time for that stuff anymore. I might play Skyrim every now and then, but that is the only game I care for really. I mainly want to have a light weight reliable laptop.
    So... because I have so much software for my windows system now, I was looking into transferring that to the MBP. Lightroom 4, AutoCAD, Word and Exel, Photoshop... ext. ext. Which brings me to question:
    Can I partition 50GB for the OS only and install all the software I have on that drive even if it wont fit on the Windows 7 partition?
    In other words
    Do I have to calculate how much space all my programs will take up for Windows 7 and partition that amount or do I only need enough space for the OS?
    I have never owned a Mac and am not familiar with the OS, I was debating if I should partition 500Gigs and slowly transition from Windows to iOS and maybe one day get rid of the Windows partition and just have the iOS on there.
    I don't know... that's why I am here... Apple has a great community so let the advising commence... haha.
    Thanks for the help.
    Dallo
    Forgot to mention: If I do get a MBPR it will be the 2.6GHz, 16GB Ram and 512GB Flash

    It's recommended to create the partition with enough space for your programs, but if you create a very small partition, install Paragon Camptune X or WinClone to resize the Windows partition

  • HT204053 How do I get a refund when I got over charged? (I clicked one storage space for iCloud for $40, then changed my mind and clicked the $100 and got charged for both.

    I logged in to iCloud to pay for backup storage. I clicked on the 20GB option for $40, then changed my mind and clicked on the $100 for 50GB storage space. I thought the $100 50GB would over ride the $40 for 20GB, but I got charged for both.
    How do I get a refund?  Also I don't really know how much space I really need on iCloud.
    Thank you for your answer. :)

    This has always been an unclear topic; Apple has said you can contact them within 15 days for an iCloud storage refund, but has not said what the appropriate contact is. Maybe someone else has done this before.

  • Can I buy more storage space for my IPAD2

    I have a 16G IPAD2. Is it possible to buy more memory for it?

    No. iPad's storage space cannot be updated. What you buy is what you stay with.
    You can however, either sell the iPad and buy one with more storage or pursue external storage solutions for it such as:
    http://www.sandisk.com/products/wireless/flash-drive/
    Or
    http://www.kingston.com/us/wireless/wireless_readers#mlw221

  • Not enough free storage space for ios update

    My wife's iPad Air MD786LL/A with 32GB. Running iOS 8.0.2. I bought it for her last year for her birthday to replace her old iPad. She won't give up the old iPad. I keep her iPad Air up to date from time-to-time but when I tried to update the iOS, it said there was not enough free storage space (requires 2.4GB and the iPad Air only has 1.8GB). She also has a MacBook Air running Yosemite and an iPhone 4S on iOS 8.2. The old iPad runs iOS 7 and won't do the multi-device sync with MBA and iPhone (which is why I was trying move her to the  more modern iOS). I need to free up some space on iPad Air.
    Songs: 278
    Videos: 40
    Photos: 7,695
    Apps: 50
    I note that Settings>General>About does not list Books in the list of things on the iPad Air. Why is this?
    Everything syncs to iCloud.
    Q: can I delete photos on the iPad Air without removing them from her MacBook Air or iPhone?
    I note that the iCloud Photos is still Beta. When I went to turn that on, it said that the 7,695 photos would be removed from the other devices. I did not proceed.
    Q: How does one move a book back to the cloud after it has been read? This should free up space.

    See: Update the iOS software on your iPhone, iPad, and iPod touch - Apple Support
    Scroll down to "Update your device using iTunes" and follow those steps.

Maybe you are looking for