Board logo

标题: [原创代码] PowerShell显示所有硬盘和U盘(可移动驱动器)的名称,类型,序列号,容量 [打印本页]

作者: a20150604    时间: 2019-11-22 15:16     标题: PowerShell显示所有硬盘和U盘(可移动驱动器)的名称,类型,序列号,容量

  1. mode 160
  2. Get-PhysicalDisk | ForEach-Object {
  3. # Number FriendlyName               SerialNumber         MediaType   CanPool OperationalStatus HealthStatus Usage            Size
  4.     Write-Host FriendlyName `t $_.FriendlyName
  5.     Write-Host SerialNumber `t $_.SerialNumber
  6.     Write-Host MediaType    `t $_.MediaType
  7.     Write-Host Size         `t`t $_.Size`n`n
  8. }
  9. Get-WmiObject Win32_DiskDrive | ForEach-Object {
  10.   $disk = $_
  11.   $partitions = "ASSOCIATORS OF " +
  12.                 "{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " +
  13.                 "WHERE AssocClass = Win32_DiskDriveToDiskPartition"
  14.   Get-WmiObject -Query $partitions | ForEach-Object {
  15.     $partition = $_
  16.     $drives = "ASSOCIATORS OF " +
  17.               "{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " +
  18.               "WHERE AssocClass = Win32_LogicalDiskToPartition"
  19.     Get-WmiObject -Query $drives | ForEach-Object {
  20.         get-partition -DriveLetter $_.DeviceID.subString(0, 1) | get-disk
  21.         Write-Host $_.DeviceID
  22.     }
  23.   }
  24.   Write-Host $_.MediaType`n`n
  25. }
  26. Read-Host -Prompt "Press Enter to exit"
复制代码

作者: lililala6868    时间: 2020-6-8 00:56

福彩3Dhttps://1680380.com/view/fc3D/index.html
上海快3https://1680380.com/view/kuai3_shft/kuai3_index.html
北京快3https://1680380.com/view/kuai3_beijing/kuai3_index.html




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2