Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for disks.ps

(view source code of disks.ps as plain text)

  1. param(
  2. 	[parameter( ValueFromRemainingArguments = $true )]
  3. 	[string[]]$Args # Leave all argument validation to the script, not to PowerShell
  4. )
  5.  
  6.  
  7. ########
  8. # Help #
  9. ########
  10.  
  11. if ( ( $Args.Length -gt 0 ) -or ( $HOME[0] -eq '/' ) ) {
  12. 	Clear-Host
  13. 	Write-Host
  14. 	if ( $HOME[0] -eq '/' ) {
  15. 		# Linux
  16. 		Write-Host "Disks.ps1 is for Windows only"
  17. 		Write-Host
  18. 	}
  19. 	Write-Host "Disks.ps1,  Version 1.00"
  20. 	Write-Host "List physical harddisks and their manufacturer, model, size, bus type, physical location and more"
  21. 	Write-Host
  22. 	Write-Host "Usage:    " -NoNewline
  23. 	Write-Host "powershell  . Disks.ps1" -ForegroundColor White
  24. 	Write-Host
  25. 	Write-Host "Notes:    This script does " -NoNewline
  26. 	Write-Host "not" -NoNewline -ForegroundColor White
  27. 	Write-Host " require elevated privileges."
  28. 	Write-Host
  29. 	Write-Host "Credits:  Sorting by device ID based on tip by Frode F"
  30. 	Write-Host "          https://stackoverflow.com/a/15040557" -ForegroundColor DarkGray
  31. 	Write-Host
  32. 	Write-Host
  33. 	Write-Host "Written by Rob van der Woude"
  34. 	Write-Host "http://www.robvanderwoude.com"
  35. 	Write-Host
  36.  
  37. 	exit 1
  38. }
  39.  
  40. Get-PhysicalDisk | Select BusType,DeviceID,FirmwareVersion,Manufacturer,MediaType,Model,PhysicalLocation,SerialNumber,Size | Sort-Object { [int]$_.DeviceID }
  41.  

page last uploaded: 2019-01-21, 22:48