![]() I have a script I use to backup data using robocopy. Get-Disk |Where-Object PartitionStyle -eq 'RAW' |Initialize-Disk -PartitionStyle MBR -PassThru |New-Partition -AssignDriveLetter -UseMaximumSize |Format-Volume -FileSystem NTFS -Confirm:$false It is convenient to use it when connecting a new disk: The next PowerShell one-liner will initialize all new connected RAW-type disks, create the partition table on them and create an NTFS partitions with the maximum available size. If there are OEM partitions on a disk ( OEM recovery partition, EFI partition, System Reserved), use the RemoveOEM parameter to remove them:Ĭlear-Disk -Number 1 -RemoveData –RemoveOEM To delete all partitions from disks and completely clear data, run the commandĬlear-Disk -Number 1 -RemoveData -Confirm:$false Get-Partition –DiskNumber 1,2 | Remove-Partition -Confirm:$false To remove all partitions on disks 1 and 2 without confirmation, run this command: Let’s format new partition in the NTFS and set the DBData volume label:įormat-Volume -DriveLetter L -FileSystem NTFS -NewFileSystemLabel DBData -Confirm:$false Set-Partition -DriveLetter U -IsActive $true Formatting a partition with PowerShell If you want to make a partition active, this command is used: ![]() Resize-Partition -DriveLetter L -Size $MaxSize $MaxSize = (Get-PartitionSupportedSize -DriveLetter L).SizeMax Then you can extend the size of the partition to the maximum: Get-PartitionSupportedSize -DriveLetter L | Format-List If you want to expand the existing partition, first of all display the available unallocated space to extend this partition: Set-Partition –DriveLetter L -NewDriveLetter U You can change the assigned letter using this command: New-Partition –DiskNumber 1 -AssignDriveLetter –UseMaximumSize #Disk inventory x maybe you go not have sufficient windows#To assign a letter automatically, the AssignDriveLetter parameter is used ( sometimes Windows doesn’t assign a drive letter automatically ). If you want the partition to occupy all available disk space, use the UseMaximumSize attribute. New-Partition –DiskNumber 1 -Size 10gb -DriveLetter L Let’s create a 10 GB partition and assign the letter L: to it: ![]() To create a new partition on a disk, the New-Partition cmdlet is used. You can try to recover the partition table and data on your RAW disk as follows. Please note that a disk may have the RAW status when the partition table is corrupted. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |