Using PowerShell statistics server C disk space

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.