SCVMM 2012 R2

Is there a powershell command to tell me how much space is on the VM Host machine for each each Virtual Machine.

How much disk space on each VM & how much space remaining.

Is there a powershell for this output?
Thx
zero000koolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bigeven2002Commented:
Hello,

I am referencing this article here.

To view the disk space and free space, use the command below.  You may need to choose Run As Administrator when opening PowerShell.
Get-WmiObject -Class Win32_logicaldisk -ComputerName Server01

Open in new window


This will output the information as follows:
Device ID (drive letter)
DriveType
ProviderName
FreeSpace (in bytes)
Size (in bytes)
VolumeName

While the free space and size are in bytes, the link above also references how to convert this to GB.  Create a new powershell file and save it with the code below (the file will need to be ran with admin privileges):

function Get-HostProperties{

param ($computerName = (Read-Host "Enter Server Name")
)
Get-WmiObject -Class win32_logicaldisk -ComputerName $computerName | ft DeviceID, @{Name="Free Disk Space (GB)";e={$_.FreeSpace /1GB}}, @{Name="Total Disk Size (GB)";e={$_.Size /1GB}} -AutoSize
}
Get-HostProperties
$HOST.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | OUT-NULL
$HOST.UI.RawUI.Flushinputbuffer()

Open in new window


If it says execution of scripts disabled, then create another powershell file to enable the execution:
set-executionpolicy unrestricted

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zero000koolAuthor Commented:
I run the command and get this & how do I change it to TB disk size?

Thanks
Enter Server Name: 02-abc.com

DeviceID Free Disk Space (GB) Total Disk Size (GB)
-------- -------------------- --------------------
C:           421.768157958984      2047.6572227478


Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented."
At line:8 char:1
+ $HOST.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | OUT-NULL
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NotImplementedException
 
Exception calling "FlushInputBuffer" with "0" argument(s): "The method or operation is not implemented."
At line:9 char:1
+ $HOST.UI.RawUI.Flushinputbuffer()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NotImplementedException
0
bigeven2002Commented:
I'll have to do more research to see if it can be converted to TB.  That same command worked fine for me.  Were you running it under admin privileges?  What version of power shell and windows OS are you running the script from?
0
bigeven2002Commented:
If you're running the script within the Powershell ISE, then remove the two $HOST lines at the bottom.  Below is without those lines and used to measure TB.

function Get-HostProperties{

param ($computerName = (Read-Host "Enter Server Name")
)
Get-WmiObject -Class win32_logicaldisk -ComputerName $computerName | ft DeviceID, @{Name="Free Disk Space (TB)";e={$_.FreeSpace /1TB}}, @{Name="Total Disk Size (TB)";e={$_.Size /1TB}} -AutoSize
}
Get-HostProperties

Open in new window

0
bigeven2002Commented:
Also, if you don't want several decimal spaces, you can use the script below which will return just two decimal spaces.  A little easier to ready.

function Get-HostProperties{

param ($computerName = (Read-Host "Enter Server Name")
)
Get-WmiObject -Class win32_logicaldisk -ComputerName $computerName | ft DeviceID, @{Name="Free Disk Space (TB)";e={"{0:N2}" -f ($_.FreeSpace /1TB)}}, @{Name="Total Disk Size (TB)";e={"{0:N2}" -f ($_.Size /1TB)}} -AutoSize
}
Get-HostProperties

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SCCM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.