Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

check for available hard drive space on a Virtual machine

$
0
0

I'm trying to create a powershell script that will show me how much available HD space is left on each VM

So far i have a text file call machines.txt that have a list off all the VM machines, The below is my command 

$computers = Get-Content -Path "C:\dacto\machines.txt"

Invoke-Command -ComputerName $computers -ScriptBlock {

Get-WmiObject [decimal]::round((Get-WMIObject Win32_LogicalDisk | Where-Object {$_.DeviceID -eq "C:"}).freespace / 1gb)}

But i receive the below errors 
Invalid query 
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], Managemen 
   tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C 
   ommands.GetWmiObjectCommand
 
Invalid query 
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], Managemen 
   tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C 
   ommands.GetWmiObjectCommand
can someone please help im also working on having this script automatically send me an email 
Please and Thank you 

Viewing all articles
Browse latest Browse all 6937

Trending Articles