﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Outputting to table format?</title><link>http://www.visualbasicscript.com/</link><description /><copyright>(c) VBScript Forum</copyright><ttl>30</ttl><item><title>Re:Outputting to table format? (ebgreen)</title><description>  I think to get a space between each server, I would do it like this (untested): &lt;br&gt;       &lt;br&gt;      Get-Content c:\temp\serverlist.txt | %{ gwmi Win32_LogicalDisk -Filter "DriveType=3" -Computer $_ | INSERT MASSIVE SELECT STATEMENT HERE | Format-Table -auto; ""} &lt;br&gt;       &lt;br&gt;      That "" on the end should output a blank line after each server has been processed. </description><link>http://www.visualbasicscript.com/fb.ashx?m=80530</link><pubDate>Fri, 05 Feb 2010 08:13:58 GMT</pubDate></item><item><title>Re:Outputting to table format? (ginolard)</title><description>  OK, here's the final version I've settled on but there's ONE issue. &lt;br&gt;   &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 Get-WMIObject Win32_LogicalDisk -filter “DriveType=3" -computer (Get-Content c:\temp\serverlist.txt) | ` 
 Select @{Name="Server";Expression={$_.SystemName}},` 
 @{Name="Drive";Expression={$_.DeviceID }},`
 @{Name=”Total”;Expression={([string][Math]::Round($_.size/1gb,2))+ " Gb" }},`
 @{Name=”Used”;Expression={[string][Math]::Round(($_.size-$_.freespace)/1gb,2)+ " Gb"}},`
 @{Name=”Free”;Expression={[string]([Math]::Round($_.freespace/1gb,2)) + " Gb"}},`
 @{Name=”% Used”;Expression={“{0:P2}” -f(($_.size/1gb - $_.freespace/1gb)/($_.size/1gb))}},`
 @{Name=”% Free”;Expression={“{0:P2}” -f(($_.size/1gb - $_.freespace/1gb)/($_.size/1gb))}},VolumeName| Format-Table -auto 
 &lt;/pre&gt; &lt;br&gt;   &lt;br&gt;  This produces output like this &lt;br&gt;   &lt;br&gt;  Server             Drive             Total             Used Free              % Used            % Free            Volume  &lt;br&gt;  ------             -----             -----             ---- ----              ------            ------            ------  &lt;br&gt;  SERVER1      C:                14.66             8.49              6.18 57.88 %           42.12 %           SYSTEM  &lt;br&gt;  SERVER1 D:                53.67             0.36              53.31 0.67 %            99.33 %           DATA  &lt;br&gt;  SERVER1      E: 6.17              0.05              6.11              0.88 % 99.12 %           SDMCACHE  &lt;br&gt;  SERVER2      C: 14.66             7.95              6.72              54.19 % 45.81 %           SYSTEM  &lt;br&gt;  SERVER2      D:                53.67 0.08              53.59             0.14 %            99.86 % DATA  &lt;br&gt;  SERVER2      E:                6.17              0.03 6.13              0.54 %            99.46 % SDMCACHE  &lt;br&gt;   &lt;br&gt;  And I would prefer a blank line separating the servers, so like this &lt;br&gt;   &lt;br&gt;  Server             Drive             Total             Used Free              % Used            % Free            Volume  &lt;br&gt;  ------             -----             -----             ---- ----              ------            ------            ------  &lt;br&gt;  SERVER1      C:                14.66             8.49              6.18 57.88 %           42.12 %           SYSTEM  &lt;br&gt;  SERVER1 D:                53.67             0.36              53.31 0.67 %            99.33 %           DATA  &lt;br&gt;  SERVER1      E: 6.17              0.05              6.11              0.88 % 99.12 %           SDMCACHE  &lt;br&gt;   &lt;br&gt;  SERVER2      C: 14.66             7.95              6.72              54.19 % 45.81 %           SYSTEM  &lt;br&gt;  SERVER2      D:                53.67 0.08              53.59             0.14 %            99.86 % DATA  &lt;br&gt;  SERVER2      E:                6.17              0.03 6.13              0.54 %            99.46 % SDMCACHE  &lt;br&gt;   &lt;br&gt;  Any ideas how to do that? &lt;br&gt;  </description><link>http://www.visualbasicscript.com/fb.ashx?m=80477</link><pubDate>Wed, 03 Feb 2010 08:38:30 GMT</pubDate></item><item><title>Re:Outputting to table format? (ginolard)</title><description>  Well, I've managed to do it like this now  &lt;br&gt;   &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 $drives = gwmi win32_logicaldisk -filter "drivetype=3" -ComputerName (gc c:\temp\test.txt) 
 
 $total = @{n="Total";e={"{0:N2}" -f ($_.Size/1GB)}} 
 $free = @{n="Free";e={"{0:N2}" -f ($_.FreeSpace/1GB)}} 
 $used = @{n="Used";e={"{0:N2}" -f (($_.Size-$_.FreeSpace)/1GB)}} 
 $server = @{n="Server";e={$_.__SERVER}} 
 $drive = @{n="Drive";e={$_.NAME}} 
 $volume = @{n="Volume";e={$_.VOLUMENAME}} 
 $PercentUsed=@{Name=”% Used”;Expression={‘{0:P2}’ -f(($_.Size/1gb-$_.freespace/1gb) / ($_.size/1gb))}}
 $PercentFree=@{Name=”% Free”;Expression={‘{0:P2}’ -f(($_.freespace/1gb) / ($_.size/1gb))}}
 
 $drives | Select $server,$drive,$total,$used,$free,$PercentUsed,$PercentFree,$volume | ft | Out-File c:\temp\diskspace.txt
 &lt;/pre&gt; &lt;br&gt;   &lt;br&gt;  That works just fine but it seems a bit messier than the object-oriented method above (which I can't get to work). &lt;br&gt;  </description><link>http://www.visualbasicscript.com/fb.ashx?m=80474</link><pubDate>Wed, 03 Feb 2010 02:33:12 GMT</pubDate></item><item><title>Outputting to table format? (ginolard)</title><description>  God, I feel like a newbie again with Powershell. &lt;br&gt;   &lt;br&gt;  I have the following script to get disk data  &lt;br&gt;   &lt;br&gt;  &lt;pre class="prettyprint"&gt;
 function GetData($drive) {
 #This function receives a drive object from the Win32_LogicalDisk WMI class and calculates the total size, freespace, amount used and 
 #the associated percentages.
 &amp;nbsp;&amp;nbsp;&amp;nbsp; PROCESS {
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj = New-Object PSObject
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $total = [Math]::Round($drive.size/1gb,2)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $free = [Math]::Round($drive.Freespace/1gb,2)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $used = [Math]::Round(($drive.size-$drive.Freespace)/1gb,2)
 
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $PercentUsed = ($used/$Total)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $PercentUsed = "{0:P2}" -f ($used/$Total) 
 
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $PercentFree = ($free/$Total)
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $PercentFree = "{0:P2}" -f $PercentFree
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty Server($drive.systemname) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty Drive($drive.name) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty Total($total) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty Used($used) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty Free($free) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty "% Used"($PercentUsed) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty "% Free"($PercentFree) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; $obj | Add-Member NoteProperty Volume($drive.volumename) -force
 &amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Output $obj 
 
 }
 }
 
 $currentdate = get-date # Get the current date
 Write-Output "SERVER DISK USAGE AS OF" $currentdate&amp;nbsp;&amp;nbsp; #Write the title
 
 $servers = gc c:\temp\test.txt
 
 
 foreach ($server in $servers) { 
 $disks = Get-WmiObject Win32_LogicalDisk -ComputerName $server | Where-Object {$_.DriveType -eq 3} 
 
 foreach ($d in $disks) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp; GetData $d
 &amp;nbsp;&amp;nbsp;&amp;nbsp; }
 }
 &lt;/pre&gt; &lt;br&gt;   &lt;br&gt;  The output, however, comes out like this  &lt;br&gt;   &lt;br&gt;  Server : D02DI0908216R &lt;br&gt;  Drive&amp;nbsp; : E: &lt;br&gt;  Total&amp;nbsp; : 6.17 &lt;br&gt;  Used&amp;nbsp;&amp;nbsp; : 0.05 &lt;br&gt;  Free&amp;nbsp;&amp;nbsp; : 6.11 &lt;br&gt;  % Used : 0.81 % &lt;br&gt;  % Free : 99.03 % &lt;br&gt;  Volume : SDMCACHE &lt;br&gt;   &lt;br&gt;  From what I've read on MSDN it SHOULD output in a table format (rows and columns) with column headings but I can't see to get it to do that.&amp;nbsp; Any idea what I'm doing wrong? &lt;br&gt;  </description><link>http://www.visualbasicscript.com/fb.ashx?m=80473</link><pubDate>Wed, 03 Feb 2010 01:36:39 GMT</pubDate></item></channel></rss>
