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

Checking logical disks

$
0
0

I have a PS script to search a single Server to get logicaldisks with free space.

 

I want to change this script so I can get multiple Servers logical disks with them formated by servername

I am NOT good at foreach statements what am I doing wrong?

 

$Servers = Get-Content "C:\servers.txt"

 

foreach ($ComputerName  in $Computers) {

 

 

Get-WmiObject Win32_logicaldisk -$ComputerName $Servers `

| Format-Table DeviceID, MediaType, `

@{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}}, `

@{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}}, `

@{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}} `

-AutoSize 

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles