Get hard drive info [powershell]

Why Us? Forums Business Sector Code Snippets Get hard drive info [powershell]

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1711
    Helpful
    Up
    0
    Down
    Not Helpful
    Art
    Keymaster

    Option 1: Retrieve general information

    display disk information windows powershell

    The command: get-wmiobject -class win32_logicaldisk

    Run the command get-wmiobject -class win32_logicaldisk to look up core information about each connected hard drive. The command returns drive letters and types, the overall size and free space in bytes, and the volume name.

    Drive type uses a numerical code:

    0 — Unknown
    1 — No Root directory
    2 — Removable Disk
    3 — Local Disk
    4 — Network Drive
    5 — Compact Disc
    6 — Ram Disk
    You may use filters to display only select drive types, e.g. Get-WmiObject -Class Win32_logicaldisk -Filter “DriveType =4” to display network drives only.

    Option 2: Retrieve hard drive properties
    wmic diskdrive get

    powershell2

    The command: wmic diskdrive get

    powershell1

    The core command wmic diskdrive get needs to be followed by one or multiple properties.

    The command wmic diskdrive get Name,Model,SerialNumber,Size,Status returns names, model types, serial numbers, the overall size in bytes, and the status for all connected hard drives.

    Other properties that you may retrieve include InstallDate, InterfaceType, FirmwareRevision, DefaultBlockSize, CompressionMethod, Capabilities, Availability, LastErrorCode, or PowerManagementCapabilities.

    Just add, replace, or remove any property from the command to create a custom one.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.