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

import-csv custom object

$
0
0

Hi experts.

I have csv file with more than 100 servers it contans the servername,servertype,platform

ServerServerTypePlatform
test1terminalserverterminal
test2ttsuse

 

I want to pull out the servers which have less than 10% free space.

Importing the server names from the fist column.

Get-WMIObject -ComputerName $hostname Win32_LogicalDisk | Where-Object {$_.drivetype -eq 3 -and [decimal]$_.size -gt [decimal]$thr} | select __SERVER, DriveType, VolumeName, Name, @{n='Size (Gb)' ;e={"{0:n2}" -f ($_.size/1gb)}},@{n='FreeSpace (Gb)';e={"{0:n2}" -f ($_.freespace/1gb)}}, @{n='PercentFree';e={"{0:n2}" -f ($_.freespace/$_.size*100)}},@{n='Servertype';e={"{0:n2}" -f (Import-Csv .\peer.csv | ? {$_.server -eq "$_.__SERVER"} | select -ExpandProperty "Server Type" )}} | Where-Object {[decimal]$_.PercentFree -lt [decimal]$thresholdspace}

 

the out put should be

servername servertype platform diskspace freepercent
test1              termianl   test        50            5

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles