Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

What is a basic example of going through the setup of a new disk (Initializing it, partitioning it, and formatting) it using powershell?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

Step 1: List the Disks Available to the System:

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

Step 2: Initialize the Disk:

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

The disk will now show a Partition Style (GBP) when repeating Get-Disk:

1      Red Hat VirtIO SCSI Disk Device   Online    2 GB GPT

Step 3: Setup a Partition:

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


Disk Number: 1

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

Step 4: Format the 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

See the storage cmdlets to find out more with disk management using powershell.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.