Ved at bruge denne side, du accepterer Privatlivspolitik.
Acceptere
EnterineEnterineEnterine
  • HJEM
  • Det pro
  • Teknik
  • Microsoft
    • Azurblå
    • Configmgr/SCCM
    • DPM
    • Orkester
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Kontor 365
    • Office Insider
    • Power BI
    • Skype
    • SQL Server
    • Hold
  • Windows
    • Windows Admin Center
    • Windows klient
    • Windows Server
  • SCCM-forespørgselsindsamlingsliste
Læsning: PowerShell Disks and Partitions Management
Font ResizerAa
EnterineEnterine
Font ResizerAa
  • HJEM
  • Det pro
  • Teknik
  • Microsoft
  • Windows
  • SCCM-forespørgselsindsamlingsliste
Søge
  • HJEM
  • Det pro
  • Teknik
  • Microsoft
    • Azurblå
    • Configmgr/SCCM
    • DPM
    • Orkester
    • Hyper-V
    • Microsoft Edge Insider
    • MSI
    • Kontor 365
    • Office Insider
    • Power BI
    • Skype
    • SQL Server
    • Hold
  • Windows
    • Windows Admin Center
    • Windows klient
    • Windows Server
  • SCCM-forespørgselsindsamlingsliste
IT Pro

PowerShell Disks and Partitions Management

Offentliggjort: februar 18, 2024
3 Min læst
DELE

PowerShell Disks and Partitions Management. There are about 166 (Windows 1903) PowerShell cmdlets in the Storage module in Windows 10. To display all available commands related to disk management.

Indhold
List Local Disks and PartitionsDisk Initialization in PowerShellHow to Create Partitions on a Disk?Formatting a partition with PowerShellHow to Remove Partitions from a Disk?
Get-Command -Module Storage

List Local Disks and Partitions

Display the list of local disks available in your system at the logical level.

Get-Disk | ft -AutoSize

Select only the system disk on which Windows is installed.

Get-Disk | Where-Object IsSystem -eq $True | fl

You can display Offline disks only.

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

If you need information about physical disks (the characteristics and status of physical disks on a computer), use Get-PhysicalDisk.

You can display the list of partitions on all disks.

Get-Partition

Or partitions on the specified disks only.

Get-Partition –DiskNumber 1,2

Disk Initialization in PowerShell

1. Get the disk Online;

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

2. Initialize it;

Initialize-Disk -Number 1

Som standard, a GPT (GUID) partition table is created on a disk, but if you need an MBR one.

Initialize-Disk 1 –PartitionStyle MBR

NOTE: If there are some data on the disk, you can change the partition table from MBR to GPT without removing the data using the mbr2gpt.exe værktøj.

How to Create Partitions on a Disk?

To create a new partition on a disk, de New-Partition cmdlet is used.

New-Partition –DiskNumber 1 -Size 100gb -DriveLetter G

If you want the partition to occupy all available disk space, use the UseMaximumSize attribute. To assign a letter automatically, de AssignDriveLetter parameter is used.

New-Partition –DiskNumber 1 -AssignDriveLetter –UseMaximumSize

You can change the assigned letter.

Set-Partition –DriveLetter L -NewDriveLetter U

If you want to make a partition active.

Set-Partition -DriveLetter U -IsActive $true

Formatting a partition with PowerShell

Format the new partition in the NTFS and set the Data volume label.

Format-Volume -DriveLetter G -FileSystem NTFS -NewFileSystemLabel Data -Confirm:$false

How to Remove Partitions from a Disk?

Remove all partitions on disks 1 og 2 without confirmation.

Get-Partition –DiskNumber 1,2 | Remove-Partition -Confirm:$false

To delete all partitions from disks and completely clear data.

Clear-Disk -Number 1 -RemoveData -Confirm:$false
TAGGET:Microsoft Windows ServerPowerShellWindowsWindows 10
Forrige artikel Office Insider 1910 til Windows
Næste artikel Azure AD Connect Error stopped-deletion-threshold-exceeded
Efterlad en kommentar Efterlad en kommentar

Efterlad et svar Annuller svar

Din e-mailadresse vil ikke blive offentliggjort. Påkrævede felter er markeret *

Denne side bruger Akismet til at reducere spam. Lær, hvordan dine kommentardata behandles.

Oversættelse

English中文(简体)DanskNederlandsFrançaisDeutschItaliano한국어PolskiPortuguêsRomânăEspañolУкраїнська
ved Transposh - translation plugin for wordpress

Populære indlæg

Systemkrav til Windows Server 2016
Windows Server
Configuration Manager Forespørgselsindsamlingsliste
Configuration Manager Forespørgselsindsamlingsliste
Configmgr
Struktureret/administreret navigation aktiveret på moderne sider i klassiske teamwebsteder
Teknik
SCCM Kunne ikke hente DP-placeringer som den forventede version fra MP
Configmgr

Seneste indlæg

Installation og konfiguration af Fail2ban til SSH-beskyttelse på Ubuntu 24.04
Linux
Aktivering og konfiguration af FirewallD på AlmaLinux
Linux
Brugeroprettelse og SSH-nøgleopsætning i AlmaLinux
Linux
Sådan nulstiller du adgangskoden på AlmaLinux
Linux

© 2023 Enterine

Gå til mobil version
Velkommen tilbage!

Log ind på din konto

Brugernavn eller e-mail-adresse
Adgangskode

Mistet din adgangskode?