Wednesday, May 2, 2018

Get space utilization of all disk from a computer


[CmdletBinding ()]
param(
        [Parameter(Mandatory =$True, ValueFromPipeline=$True )]
        [string[]] $ComputerName
    )
ForEach ( $Name in $ComputerName ) {
    write-host "Drive info for " $Name
    Get-WmiObject -Class win32_logicaldisk -ComputerName $Name |
ft DeviceID , @{Name= "Free Disk Space (GB)";e= {$_.FreeSpace /1GB }}, @{Name ="Total Disk Size (GB)";e ={$_ .Size / 1GB}} -AutoSize

No comments:

Post a Comment

Thank you for your comment.