PoshCode Archive  Artifact Content

Artifact 195a088ebe9d3300aec669a96fc8a3d5b311f2b36483118532cd02280a66f539:

  • File get-sandisks.ps1 — part of check-in [77bc4303a2] at 2018-06-10 13:47:12 on branch trunk — This is a simple script to get the number of physical drive, their type and Storage on remoter computers (user: unknown size: 1060)

# encoding: ascii
# api: powershell
# title: 
# description: This is a simple script to get the number of physical drive, their type and Storage on remoter computers
# version: 0.1
# type: function
# license: CC0
# function: get-sandisks
# x-poshcode-id: 4870
# x-archived: 2014-04-09T16:41:05
#
# Note: you must pass input file name and output file name
#
Function get-sandisks ([string]$InputFilename,[string]$OutputFilename)
{
$strComputer = gc $InputFilename
$MyObj = @()
foreach ($server in $strComputer) {
$colItems = get-wmiobject -class "Win32_DiskDrive" -namespace "root\CIMV2" -computername $server
foreach ($objItem in $colItems) { 
$Rep = "" | select "Server Name", "Disk", "Disk Space", "Type"
      $Rep."Disk" = $objItem.DeviceID 
      $Rep."Type" = $objItem.Model 
      $Rep."Disk Space" = ([Math]::Round($objItem.Size/1gb, 2)) 
      $Rep."Server Name" = $objItem.SystemName 
      $MyObj += $Rep
      #$MyObj
      $rep = $null}
      }
 $MyObj | sort | Export-Csv -Path $OutputFilename -NoTypeInformation
}