Chart-DiskSpace on local and remote server


posted by Sylvain LESIRE
12-12-2008

Downloads: 2,263
File size: 1.6kB
Views: 7,582

Embed
Chart-DiskSpace on local and remote server
  1. # This script creates graphical Report by using logparser and WMI 
  2. # for a set of remote server and localhost 
  3.  
  4. # usage : 
  5. # With a list of remote computers 
  6. # cmdline 
  7. #   get-content MyServerList.txt | chart-driveSpace.V2.ps1 
  8.  
  9. # MyServerList.txt is a list of remote servers 
  10.  
  11. # localhost 
  12. # cmdline 
  13. # run script like that : & .\chart-driveSpace.V2.ps1 
  14.  
  15.  
  16. ############# 
  17. #pre-requist# 
  18. ############# 
  19. # logparser version 2.2  
  20. # Micrososft office or Microsoft Office Web Components 
  21.  
  22. begin { 
  23.     # function found on http://www.blkmtn.org/sepeck 
  24.     function Get-DriveSpace([string]$SystemName ) { 
  25.         $driveinfo = get-wmiobject win32_logicaldisk -filter "drivetype=3 or drivetype=4" -computer $SystemName  
  26.         $driveinfo | select deviceid, ` 
  27.         @{Name="FreeSpace";Expression={($_.freespace/1GB).tostring("0.00")}}, ` 
  28.         @{Name="DriveSize";Expression={($_.size/1GB).tostring("0.00")}}, ` 
  29.         @{Name="Percentfree";Expression={((($_.freespace/1GB)/($_.size/1GB))*100).tostring("0.00")}} 
  30.     
  31.      
  32.  
  33. Process { 
  34. $logparser = "c:\Program Files\Log Parser 2.2\LogParser.exe" 
  35. $serverName =  $_ 
  36.  
  37. if ($serverName -eq $Null) { 
  38.     $serverName= $env:COMPUTERNAME 
  39.  
  40. Get-DriveSpace $serverName | Export-Csv $env:temp"\temp.csv" -NoTypeInformation 
  41. & $logparser "select deviceid, TO_REAL (REPLACE_CHR (percentfree, ',', '.')) as purcentage into chart_$serverName.gif from $env:temp\temp.csv order by deviceID desc" "-o:chart" "-charttype:BarStacked" "-charttitle:Purcentage : FreeSpace by disk              Server:$serverName" "-values:ON" "-categories:ON" "-maxCategoryLabels:100" 
  42. Invoke-Item .\"chart_"$serverName".gif" 

This script creates graphical Report by using logparser and WMI
for a set of remote server and localhost

usage :
With a list of remote computers
cmdline
  get-content MyServerList.txt | chart-driveSpace.V2.ps1

MyServerList.txt is a list of remote servers

localhost
cmdline
run script like that : & .\chart-driveSpace.V2.ps1


#pre-requist#

logparser version 2.2
Micrososft office or Microsoft Office Web Components

Comments

garreja wrote re: Chart-DiskSpace on local and remote server
on 02-16-2010 12:59 PM

Sylvain,

I'm new to powershell and I like the idea of graphical disk reports.  When I run your script with powershell v2 on a Windows 7 x64 system.  I get the following error:

PS C:\Users\garreja.FEG\Documents\Scripts> get-content myserverlist1.txt | &.\ch

art-drivespace.ps1

The script failed due to call depth overflow.  The call depth reached 1001 and

the maximum is 1000.

   + CategoryInfo          : InvalidOperation: (1001:Int32) [], ParentContain

  sErrorRecordException

   + FullyQualifiedErrorId : CallDepthOverflow

Can you give me an idea of what I'm doing wrong?

Thank you

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.