Click here to Skip to main content
11,707,470 members (59,855 online)
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 Corey101.1K
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 OriginalGriff 156
1 Sergey Alexandrovich Kryukov 145
2 Mika Wendelius 140
3 chainerlt 110
4 ppolymorphe 104
0 OriginalGriff 9,178
1 Sergey Alexandrovich Kryukov 8,562
2 CPallini 5,189
3 Maciej Los 4,806
4 Mika Wendelius 3,706


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2015
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