Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PowerShell
How to use PowerShell script that will show the free space on the C: drive of your virtual windows machine.

 
Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" -computer localhost | Select SystemName,DeviceID,VolumeName,@{Name="Size(GB)";Expression={[decimal]("{0:N1}" -f($_.size/1gb))}},@{Name="Free Space(GB)";Expression={[decimal]("{0:N1}" -f($_.freespace/1gb))}},@{Name="Free Space(%)";Expression={"{0:P2}" -f(($_.freespace/1gb) / ($_.size/1gb))}} | Out-GridView -Title "Drive Space"

 
This code just can show the local machine. How to show the virtual window machine?
Posted 3-Jul-12 2:39am
Evan Ng101
Edited 3-Jul-12 2:40am
Tim Corey87.9K
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You will need to have network access to your virtual machine if you want to use this particular script. Once you set up your virtual machine to be on your local network like any other physical machine, you can then access it via name or IP address. You would change the "-computer localhost" to be "-computer {VM_MachineName}". Just make sure your VM has its firewall open to accept this type of connection.
 
If you want to connect to the Virtual Machine host software and get the space of the running virtual machines that way, you will need a different script. Those are usually specific to which type of Virtual Machine hypervisor you use. Here is a forum with a couple different examples that might be relevant to your situation:
 
http://communities.vmware.com/message/1701655[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 646
1 OriginalGriff 385
2 CPallini 240
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,795
1 Sergey Alexandrovich Kryukov 5,158
2 CPallini 4,740
3 George Jonsson 3,167
4 Gihan Liyanage 2,450


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100