0% found this document useful (0 votes)
36 views4 pages

Disk Management

This document provides instructions for managing disks and storage on a Windows Server using PowerShell commands. It covers listing disks, formatting disks by clearing partitions and data, initializing disks, creating partitions and assigning drive letters, listing partitions and volumes, formatting volumes to NTFS file system, and deleting partitions.

Uploaded by

Yrreg Gerry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

Disk Management

This document provides instructions for managing disks and storage on a Windows Server using PowerShell commands. It covers listing disks, formatting disks by clearing partitions and data, initializing disks, creating partitions and assigning drive letters, listing partitions and volumes, formatting volumes to NTFS file system, and deleting partitions.

Uploaded by

Yrreg Gerry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Disk Management

1. List disks
Before you can begin configuring and managing your Windows Server storage, you first need to fetch
the list of disks presented on the machine using PowerShell.

# List all disks


Get-Disk

# List disks that are not system disks


# to avoid accidently formatting your system drive
Get-Disk | Where-Object IsSystem -eq $False

# List disks that are offline


Get-Disk | Where-Object IsOffline –Eq $True

Activity 1:

2. Format a disk (Warning: Do not execute the foregoing commands in you unit, it will erase your entire
data and can not be recovered anymore)
Having new disks present on the server is a totally different case, but there may be scenarios where
you want to format existing disks and then create partitions and volumes. You can use the Clear-Disk
cmdlet to remove all partition information and uninitialize it, which will erase the data on the disk.

This is an unrecoverable process, so please make sure to back up your disk before running the
command.

# Clear a blank disk with the disk number


Clear-Disk -Number 1
Disks can contain both data and OEM partitions, and you can very easily remove them from the disk
using the switch parameters -RemoveData and -RemoveOEM.

# Clear a target disk with data partitions


Clear-Disk -Number 1 –RemoveData

# Clear a disk regardless of whether it contains data or OEM partitions


Clear-Disk -Number 1 -RemoveData –RemoveOEM

3. Initialize a disk
A new disk or a cleaned disk using the cmdlet mentioned above is in an uninitialized state, and you
have to initialize it first using the disk number of the target disk.
Initialize-Disk -Number 2

By default, this initializes all disks as GUID Partition Tables (GPTs) unless explicitly specified, and you
can use the -PartitionStyle parameter to initialize a disk as a Master Boot Record (MBR).
Initialize-Disk 4 –PartitionStyle MBR

If the disk has recently just become present on the server, it will be in a raw partition style state. You
can easily target and initialize such disks using the following command:

Get-Disk | Where-Object PartitionStyle –Eq 'RAW' | Initialize-Disk

4. Create a partition and volume


To create a partition, which is basically a block of data on the disk, you can run the New-Partition
cmdlet with the -AssignDriveLetter and -UseMaximumSize switches to choose the available and
allowed drive letter with the maximum size available on the disk.

New-Partition –DiskNumber 3 -AssignDriveLetter –UseMaximumSize


You can also explicitly specify the disk size and drive letter.
New-Partition –DiskNumber 4 -Size 150gb -DriveLetter h

After partitioning the disks, you can list them to see the current status:

# Listing partitions on specific disks


Get-Partition –DiskNumber 0,2,3

After creating the partitions, they are still not accessible from the File Explorer. You have to create
new volumes in a format (like NTFS) that the operating system understands.

# List all volumes


Get-Volume

# Format volumes with NTFS


Format-Volume -DriveLetter F,H -FileSystem NTFS -Confirm:$false
5. Delete a partition
To delete any partition on a disk, you can target it with the disk number and then pipe it to the
Remove-Partition cmdlet

# Delete a partition
Get-Partition –DiskNumber 2,3 | Remove-Partition -Confirm:$false

You might also like