Powershell 2.0 (Windows 7) 에서 디스크 정보 확인하는 방법

 

 

Powershell 버전을 확인할려면

Get-Host 또는 $Host 를 치면 된다.

 

 

디스크 정보 확인

 

명령

 

 Clear-Host
Get-WmiObject Win32_logicaldisk -ComputerName LocalHost `
| Format-Table DeviceID, MediaType, `
@{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}}, `
@{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}}, `
@{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}} `
-AutoSize

 

결과

 

 DeviceID MediaType Size(GB) Free Space(GB) Free (%)
-------- --------- -------- -------------- --------
C:              12      120             20   17 %
D:              12      932            918   99 %
E:              11        0              0

 

 

 

 

명령

Clear-Host
Get-WmiObject Win32_logicaldisk | Format-Table -auto 

 

결과

 DeviceID DriveType ProviderName                   FreeSpace          Size Volum
                                                                          eName
-------- --------- ------------                   ---------          ---- -----
C:               3                              21589057536  128849014784
D:               3                             985416155136 1000202039296
E:               5

 

 

 

  

명령

Clear-Host
Get-WmiObject -query "Select * from Win32_logicaldisk" |Ft  

 

결과

 DeviceID          DriveType ProviderName    FreeSpace         Size VolumeName
--------          --------- ------------    ---------         ---- ----------
C:                        3               21589032960 128849014784
D:                        3              985416155136 ...202039296
E:                        5

 

 

 

 

명령

Get-WmiObject Win32_logicaldisk `
| Format-Table DeviceId, MediaType, Size, FreeSpace -auto 

 

결과

 DeviceId MediaType          Size    FreeSpace
-------- ---------          ----    ---------
C:              12  128849014784  21589032960
D:              12 1000202039296 985416155136
E:              11

 

 

 

 

명령

Get-WmiObject -query "Select * from Win32_logicaldisk" `
| Format-Table $Item -auto  

 

결과

 DeviceId MediaType          Size    FreeSpace
-------- ---------          ----    ---------
C:              12  128849014784  21589032960
D:              12 1000202039296 985416155136
E:              11

 

 

 

 

명령

Clear-Host
Get-WmiObject Win32_logicaldisk -ComputerName LocalHost `
| Format-Table DeviceID, MediaType, `
@{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}}, `
@{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}}, `
@{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}} `
-AutoSize 

 

결과

DeviceID MediaType Size(GB) Free Space(GB) Free (%)
-------- --------- -------- -------------- --------
C:              12      120             20   17 %
D:              12      932            918   99 %
E:              11        0              0 

 

 

 

 

명령

Clear-Host
$Item = @("DeviceId", "MediaType", "Size", "FreeSpace")
# Next follows one command, which is split over three lines by the backtick `
Get-WmiObject -computer LocalHost -query `
"Select $([string]::Join(',', $Item)) from Win32_logicaldisk" `
| Sort MediaType, DeviceID | Format-Table $item -auto -groupby MediaType 

 

결과

    MediaType: 11

DeviceId MediaType Size FreeSpace
-------- --------- ---- ---------
E:              11


   MediaType: 12

DeviceId MediaType          Size    FreeSpace
-------- ---------          ----    ---------
C:              12  128849014784  21589032960
D:              12 1000202039296 985416155136

 

 

 

 

명령

$Item = @("DeviceId", "MediaType", "Size", "FreeSpace")
Clear-Host
# Next follows one command split over four lines by a backtick `
Get-WmiObject -computer LocalHost -query `
"Select $([string]::Join(',',$Item)) from Win32_logicaldisk `
Where MediaType=12" | Sort-Object MediaType, DeviceID `
| Format-Table $item -auto  

 

결과

 DeviceId MediaType          Size    FreeSpace
-------- ---------          ----    ---------
C:              12  128849014784  21589032960
D:              12 1000202039296 985416155136

 

 

 

 

 

명령

Clear-Host
$Item = @("Name","DiskIndex", "StartingOffset", "Bootable", "BlockSize", "NumberOfBlocks")
Get-WmiObject -query "Select * from Win32_DiskPartition" | Format-Table $item -auto  

 

결과

Name                  DiskIndex StartingOffset Bootable BlockSize NumberOfBlock
                                                                              s
----                  --------- -------------- -------- --------- -------------
Disk #0, Partition #0         0        1048576     True       512        204800
Disk #0, Partition #1         0      105906176    False       512     251658240
Disk #1, Partition #0         1        1048576    False       512    1953519616
 

 

 

반응형
Posted by 미니도라
,