Advance

PowerShell Commands for Working with Hard Disk

PowerShell commands for working with hard disk
1
(1)

PowerShell Commands for Working with Hard Disk. PowerShell commands for working with the hard disk, like the other PowerShell commands that we explained to you in the Powershell tutorial, have a uniform structure.

In CMD, you must use external commands such as Diskpart to use commands that are not in the Command Prompt kernel. But given the power and evolution of PowerShell in Windows, you will have all the commands available with one structure.

In this article, we want to acquaint you with PowerShell commands for working with hard disk so that you can use it to manage and partition all storage devices such as USB Flash Disk, Hard Disk, SD Card, etc.

 

Choose your perfect Windows Virtual Private Server Packages in Eldernode

 

In this article, in order to be useful and understand the instructions for working with hard disks, we will explain in a complete scenario:

The parts of this scenario are:

1- Remove all information and partitioning from a Flash

2- Redistribute it

3- Format and assign a name and Drive Letter to it

Recommended Article: Answer To MySQL Queries Troubleshooting

PowerShell commands for working with hard disk

1- First, open PowerShell with Administrator access.

2- Then enter the following command to get the information of the hard disks connected to the system:

Get-Disk

As you can see in the image below, by entering the above command, complete information of the connected hard disks will be displayed for you:

 

PowerShell commands for working with hard disk

 

3- Then enter the following command to delete the data and partition on the desired disk.

Clear-Disk -Number 3 -RemoveData

 

By entering the above command, you have instructed PowerShell to select the disk with the -number 3 specified in the Get-Disk section and delete all its information.

After executing the command, PowerShell will ask you to confirm the deletion of all data and the selected disk partition, which you will allow operation by entering Y.

 

PowerShell commands for working with hard disk

 

4- After deleting all the information from the flash, we enter the following command to create a new partition:

New-Partition -DiskNumber 3 -UseMaximumSize -IsActive -DriveLetter S

 

The above command creates a partition with the maximum size for disk one and activates it and assigns the letter S to it.

 

PowerShell commands for working with hard disk

 

Note: If you plan to make your hard disk or flash drive smaller in size, just use the phrase -Size 1GB instead of -UseMaximumSize to create a partition of the desired size. Note that instead of 1GB you will be able to enter any amount in the range of your hard disk space.

 

Example of making a partition of any size

New-Partition -DiskNumber 3 -Size 1GB -IsActive -DriveLetter S

 

5- In the end, you must format the created partition by entering the following command:

Format-Volume -DriveLetter S -FileSystem NTFS - NewFileSystemLabel USBDISK

 

After entering the above command, the flash name will be renamed to USBDISK and will be formatted with the NTFS file system.

 

PowerShell commands for working with hard disk

 

That way, with the Get-Disk, Clear-Disk, New-Partition, and Format-Volume commands, you can have complete control over your hard drives with the PowerShell commands.

 

Also, see:

Introduction to Windows PowerShell

Learn important PowerShell commands

How to download files in PowerShell

 

Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problem in it as soon as possible. Make time for other users and experts to answer your questions.

Goodluck.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day