Monday, June 23, 2008

Was recently asked to retrieve hard drive (type=3) information from a supplied list of servers for backup planning.

Following is a script used to gather this information.
Now if I could only find a way to get the file count.....

function Get-DriveInventory
#get drives from WMI
$drives = gwmi win32_logicaldisk -comp $_ -filter "drivetype=3"
#construct output objects
foreach ($drive in $drives)
$obj = New-Object psobject
$obj Add-Member NoteProperty ComputerName $_
$obj Add-Member NoteProperty DriveLetter $drive.deviceid
$obj Add-Member NoteProperty VolumeName $drive.VolumeName
$free = $drive.freespace/1MB -as [int]
$obj Add-Member NoteProperty AvailableSpace $free
$total = $drive.size/1MB -as [int]
$obj Add-Member NoteProperty TotalSpace $total
Write-Output $obj

function Get-FileName
$computer = Read-Host "Filename of computer names?"
return $computer
# get the filename
$f = Get-FileName
Get-Content $f Get-DriveInventory Export-Csv "C:\Users\Public\Documents\DriveInventory.csv"


Derek Mangrum said...

To get a file count, could you do something like....

$files = Get-ChildItem -Recurse | where {$_.PSIsContainer -eq $FALSE}

Anonymous said...

Rip Blu-ray for Mac with Blu-ray Ripper for Mac, snow Leopard included.- Free Download and have a try.
Ultimate Blu-ray video converter is actually an 3-in-one software including Blu-ray Ripper, DVD Ripper and Video Converter.
Blu-ray ripper enables you directly rip and convert your Blu-ray movies and general DVDs, even the protected DVDs and Blu-ray DVDs into other popular audio and video formats.