Bagaimana cara mengatur (menginisialisasi, partisi, dan memformat) disk menggunakan Powershell?

Jawaban:

17

Langkah 1: Sebutkan Disk yang Tersedia untuk Sistem:

PS C:\> Enter-PSSession -ComputerName 192.168.1.193 -Credential administrator
PS C:\> Get-Disk

Number Friendly Name                            OperationalStatus                    Total Size Partition Style
------ -------------                            -----------------                    ---------- ---------------
0      Red Hat VirtIO SCSI Disk Device          Online                                    20 GB MBR
1      Red Hat VirtIO SCSI Disk Device          Offline                                    2 GB RAW

Langkah 2: Inisialisasi Disk:

[192.168.1.193]: PS C:\Users\Administrator\Documents> Initialize-Disk -Number 1

Disk sekarang akan menampilkan Partition Style (GBP) ketika mengulangi Get-Disk:

1      Red Hat VirtIO SCSI Disk Device   Online    2 GB GPT

Langkah 3: Mengatur Partisi :

PS C:\> New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter


Disk Number: 1

PartitionNumber  DriveLetter Offset        Size     Type
---------------  ----------- ------        ----     ----
2                D           33619968      1.97 GB  Basic

Langkah 4: Format Volume:

PS C:\> Format-Volume -DriveLetter D

Confirm
Are you sure you want to perform this action?
Warning, all data on the volume will be lost!
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): Y

DriveLetter       FileSystemLabel  FileSystem       DriveType        HealthStatus        SizeRemaining             Size
-----------       ---------------  ----------       ---------        ------------        -------------             ----
D                                  NTFS             Fixed            Healthy                   1.92 GB          1.97 GB

Lihat cmdlet penyimpanan untuk mengetahui lebih lanjut dengan manajemen disk menggunakan PowerShell.

Kyle Brandt
sumber