Want more features on Pastebin? Sign Up, it's FREE!
Guest

get-diskspace.ps1

By: a guest on Oct 30th, 2013  |  syntax: Power Shell  |  size: 1.11 KB  |  views: 94  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <#
  2. AboutScript
  3. #>
  4. param(
  5.         [Parameter(Mandatory=$false, ValueFromPipeline=$true)] [string] $ComputerName
  6. );
  7. BEGIN {
  8.         $jobList = @();
  9. }
  10. PROCESS {
  11.                
  12.         $jobList += Invoke-Command -ComputerName $_ -ScriptBlock {
  13.         $result1 = Get-WmiObject Win32_logicaldisk | select __Server,DeviceID,Size,FreeSpace;
  14.         $objReturn = New-Object PSobject;
  15.         $objReturn | Add-Member -MemberType Noteproperty -Name Computername -value $result1.__Server
  16.         $objReturn | Add-Member -MemberType Noteproperty -Name DeviceID -value $result1.DeviceID
  17. #       $objReturn | Add-Member -MemberType Noteproperty -Name Size_GB -value $($result1.Size/1gb)
  18.         $objReturn | Add-Member -MemberType Noteproperty -Name Size_GB -value $result1.Size
  19.         $objReturn | Add-Member -MemberType Noteproperty -Name Free_GB -value $result1.FreeSpace
  20. #       $objReturn | Add-Member -MemberType Noteproperty -Name Free_Percent_GB -value $(($result1.FreeSpace/1gb) / ($result1.Size/1gb))
  21.         $objReturn     
  22.         } -AsJob;
  23. }
  24. END {
  25.         $results = $jobList | Wait-Job | Receive-Job -ErrorAction SilentlyContinue
  26.         $results | Select * -excludeproperty PSComputerName,RunspaceId,PSShowComputerName
  27. }
clone this paste RAW Paste Data