通过使用本网站, 您同意 隐私政策.
接受
进入IT进入IT进入IT
  • 家
  • 信息技术专家
  • 技术
  • 微软
    • 天蓝色
    • 配置管理器/SCCM
    • 数字PM
    • 协调者
    • Hyper-V
    • 微软 Edge 预览体验
    • 微星指数
    • 办公室 365
    • 办公室内幕
    • 电力商业智能
    • Skype
    • SQL服务器
    • 团队
  • 视窗
    • Windows 管理中心
    • Windows客户端
    • Windows服务器
  • SCCM查询集合列表
阅读: PowerShell Disks and Partitions Management
字体调整器氨基酸
进入IT进入IT
字体调整器氨基酸
  • 家
  • 信息技术专家
  • 技术
  • 微软
  • 视窗
  • SCCM查询集合列表
搜索
  • 家
  • 信息技术专家
  • 技术
  • 微软
    • 天蓝色
    • 配置管理器/SCCM
    • 数字PM
    • 协调者
    • Hyper-V
    • 微软 Edge 预览体验
    • 微星指数
    • 办公室 365
    • 办公室内幕
    • 电力商业智能
    • Skype
    • SQL服务器
    • 团队
  • 视窗
    • Windows 管理中心
    • Windows客户端
    • Windows服务器
  • SCCM查询集合列表
IT专业人士

PowerShell Disks and Partitions Management

出版: 二月 18, 2024
3 最小阅读量
分享

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

内容
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

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

Initialize-Disk 1 –PartitionStyle MBR

笔记: 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 工具.

How to Create Partitions on a Disk?

To create a new partition on a disk, the 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, the 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 和 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
标记:微软视窗服务器Powershell视窗视窗 10
上一篇 办公室内幕 1910 对于Windows
下一篇 Azure AD Connect Error stopped-deletion-threshold-exceeded
发表评论 发表评论

发表回复 取消回复

您的电子邮件地址不会被公开. 必填字段已标记 *

该网站使用 Akismet 来减少垃圾邮件. 了解您的评论数据的处理方式.

翻译

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

热门帖子

Windows Server 的系统要求 2016
Windows服务器
配置管理器查询集合列表
配置管理器查询集合列表
configmgr
在经典团队网站的新式页面上启用结构化/托管导航
技术
SCCM 无法从 MP 获取预期版本的 DP 位置
configmgr

最近的帖子

在 Ubuntu 上安装和配置 Fail2ban 以实现 SSH 保护 24.04
Linux
在AlmaLinux上启用和配置FirewallD
Linux
AlmaLinux中的用户创建和SSH密钥设置
Linux
如何在AlmaLinux上重置密码
Linux

© 2023 进入IT

转到移动版本
欢迎回来!

登录您的帐户

用户名或电子邮件地址
密码

丢失密码?