Get-DiskSizeInfo

Winter Scripting Games - Practice Event #1 - Sizing up the Disks - You have been asked to create a Windows PowerShell advanced function named Get-DiskSizeInfo. It must accept one or more computer names, and use WMI or CIM to query each computer...

 
 
 
 
 
5 Star
(2)
2,169 times
Add to favorites
2/10/2013
E-mail Twitter del.icio.us Digg Facebook
  • can I make separate sheet with error logs in my script?
    2 Posts | Last post December 02, 2013
    • $strComputer = (get-content "Path_of_the_computer_list.txt")
      $path = "path_of_the_excel_file.xls"
      $Excel = New-Object -ComObject excel.application
      $Excel.visible = $true 
      $Workbook = $excel.Workbooks.open($path)
      $sheet = $Workbook.WorkSheets.add() 
      $sheet = $Excel.Worksheets.Item("Sheet1")
      $date=(get-date).Day
      $sheet.Name = "$date" 
      
      $Sheet.Cells.Item(1,1) = “Computer”
      $Sheet.Cells.Item(1,2) = “Drive Letter”
      $Sheet.Cells.Item(1,3) = “Description”
      $Sheet.Cells.Item(1,4) = “FileSystem”
      $Sheet.Cells.Item(1,5) = “Size in GB”
      $Sheet.Cells.Item(1,6) = “Free Space in GB”
      
      $WorkBook = $Sheet.UsedRange
      $WorkBook.Interior.ColorIndex = 8
      $WorkBook.Font.ColorIndex = 11
      $WorkBook.Font.Bold = $True
      
      $intRow = 2
      $colItems = Get-wmiObject -class “Win32_LogicalDisk” -namespace “root\CIMV2"`
      -computername $strComputer
      
      foreach ($objItem in $colItems) {
      $Sheet.Cells.Item($intRow,1) = $objItem.SystemName
      $Sheet.Cells.Item($intRow,2) = $objItem.DeviceID
      $Sheet.Cells.Item($intRow,3) = $objItem.Description
      $Sheet.Cells.Item($intRow,4) = $objItem.FileSystem
      $Sheet.Cells.Item($intRow,5) = $objItem.Size / 1GB
      $Sheet.Cells.Item($intRow,6) = $objItem.FreeSpace / 1GB
      
      $intRow = $intRow + 1
      
      }
      $WorkBook.EntireColumn.AutoFit()
      Clear
      
      $Excel.ActiveWorkBook.Save() 
      $Excel.Quit()
      Remove-Variable -Name excel
      [gc]::collect()
      [gc]::WaitForPendingFinalizers()
    • Hi Muslim,
      
      Sorry this question is not related to my script.
      
      You can ask your question on this forum, I'm sure someone will be able to answer:
      
      http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG