SHARE
TWEET

Untitled

a guest Oct 9th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Get-WmiObject Win32_LogicalDisk -comp localhost -filter "drivetype=3" | Where { ($.FreeSpace / $.Size) -lt .1 } | Select -Property DeviceID,FreeSpace,Size
  2.  
  3. function diskspace()
  4. {
  5. param(    
  6.         [string] $computername,
  7.    [int]$drivetype,
  8.         [float]$freespace)
  9.  
  10. $comp = Read-Host "enter the servername"
  11.  
  12. if($comp.Length -eq 0)
  13. {
  14.  
  15. $computername = hostname
  16. Write-Host "your local computer is $computername"
  17.  
  18.  
  19. }
  20. else
  21. {
  22. $computername = $comp
  23. Write-Host "your computer is $computername"
  24. }
  25.  
  26.  
  27. $output = Get-WmiObject Win32_LogicalDisk -comp $computername -filter "drivetype=3"| select DeviceID,@{Label="Size";Expression={$_.Size / 1gb -as [float] }},@{Label="Freespace";Expression={$_.freespace / 1gb -as [float] }}
  28. $output
  29. #$output | Export-Csv G:\SatishWindows\scripting\diskspace.csv
  30. }
  31.  
  32. diskspace
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top