Tips for output for WMI query
Posted: Thu May 08, 2008 10:03 pm
hi all,
trying to dive into powershell and make use of all the cool features but running into a snag, trying to figure out a way to output to a text file or HTML, i know there are cmdlets to do this but i cannot figure out how to pipe what i am doing to properly so i can output to the format i want.
any ideas hit on better formatting or a an easier way output the server name and drives would be appreciated!
trying to dive into powershell and make use of all the cool features but running into a snag, trying to figure out a way to output to a text file or HTML, i know there are cmdlets to do this but i cannot figure out how to pipe what i am doing to properly so i can output to the format i want.
Code: Select all
$servers=get-content ""
#query each Server in the list
foreach ($s in $servers)
{
$computer= $s
$d= get-wmiobject -computer $computer -query "select deviceid,size from win32_logicaldisk where drivetype=3"
# Cmdlet to display the size of disk partitions
foreach ( $drive in $d )
{
$s= $s + "`n" + $drive.DeviceID + [int]($drive.Size/1073741824) + " GB "
}
$s= $s + "`n"
Write-host $s
}
Write-Host "Script Completed"
any ideas hit on better formatting or a an easier way output the server name and drives would be appreciated!