Recently hit patch, because the server C disk space is not much of the results generated a lot of alarm, although not very serious but this problem can be avoided, wrote a very simple script to detect the server C disk space, and you share
First you need to gather information about the server, primarily the FQDN, and then list the information in a CSV file, read the CSV file, then execute a script block for each server, and then output the results to the console
Share the contents of the script below
Get-content "E:\abc.csv" | %{
Invoke-command-computername $_-scriptblock {
$name = ""
$size = 0
$name = (Get-wmiobject-class win32_computersystem). Name + "." + (Get-wmiobject-class win32_computersystem). Domain
$size = ((Get-wmiobject Win32_LogicalDisk |? {$_.deviceid-match "C"}). FreeSpace)/1GB
if ($size-lt 15)
{
Write-host-foregroundcolor ' red '-backgroundcolor ' Cyan ' ($name + "free Space C: {0:n1} GB"-f $size)
}
Else
{
Write-host ($name + "free Space C: {0:n1} GB"-f $size)
}
}
}
Read-host
This set is the C drive 15G below will be output in other colors, or can be manually modified as needed, the script is very simple to run, right click on the use of PowerShell to run. Here are the results
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/71/AE/wKioL1XWxF6RFDwdAAGT335bLZM010.jpg "title=" Untitled picture.png "alt=" Wkiol1xwxf6rfdwdaagt335blzm010.jpg "/>
This article is from the "Just Make It Happen" blog, so be sure to keep this source http://mxyit.blog.51cto.com/4308871/1686832
Using PowerShell statistics server C disk space