ISD-PLC
asked on
Powershell - diskspace query
Hi,
I am trying to create a powershell script to query servers and return the drive size and used space but I'm runing into issues..
current script is (attached as well to get round cut/paste issue)
$servers = Get-Content C:\scripts\diskspace\serve rs.txt
$DriveSize = foreach($server in $servers){
Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" -computer $server `
| Select SystemName,DeviceID,Volume Name,`
@{Name="Size(GB)";Expressi on={[decim al]("{0:N1 }"-f($_.si ze/1gb))}} ,`
@{Name="Used Space(GB)";Expression={[de cimal]("{0 :N1}"-f(($ _.size/1gb )-($_.free space/1gb) ))}},`
@{Name="Used Space(%)";Expression={"{0: P2}"-f((($ _.size/1gb )–($_.free space/1gb) )/($_.size /1gb))}}
}
$DriveSize | Out-GridView -Title 'Drive Size'
$DriveSize | Export-CSV C:\scripts\diskspace\serve rs\drive.c sv -NoType
Im getting errors related to missing terminators. I want to get this work so I can move on to adding cpu/ram info.
Thanks for any pointers...
DiskSpaceReport4.txt
I am trying to create a powershell script to query servers and return the drive size and used space but I'm runing into issues..
current script is (attached as well to get round cut/paste issue)
$servers = Get-Content C:\scripts\diskspace\serve
$DriveSize = foreach($server in $servers){
Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" -computer $server `
| Select SystemName,DeviceID,Volume
@{Name="Size(GB)";Expressi
@{Name="Used Space(GB)";Expression={[de
@{Name="Used Space(%)";Expression={"{0:
}
$DriveSize | Out-GridView -Title 'Drive Size'
$DriveSize | Export-CSV C:\scripts\diskspace\serve
Im getting errors related to missing terminators. I want to get this work so I can move on to adding cpu/ram info.
Thanks for any pointers...
DiskSpaceReport4.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Luckily attaching the script as you did made it very easy to spot.
ASKER
Thanks very much much appreciated.
ASKER
Now to work out how to add a CPU and RAM query....