Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

import-csv custom colums

$
0
0

Hi team,

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

ServerServerTypePlatform
test1terminalserverterminal
test2ttsuse

I am trying to get the server which are having 10% less drive space.

$drive  = 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} | ConvertTo-HTML -fragment

the above command gives me the servers which have less than 10% free space on the drive.

My question is how can i import this csv file  and even add the objects like servertype and platform to the output

note - this is a part of a big script which does mulitple thinks. i need the output in html format.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>