我正在尝试以编程方式格式化分区。到目前为止,我已经尝试过PowerShell来做这件事,但似乎需要一个“量”才能这样做。
要获取我要格式化的分区,我使用:
$partition = get-disk -number 3 | get-partition | where Guid -eq "{0cdf62cf-64ac-468c-8d84-17292f3d63b7}"
我接下来应该怎么做呢?
我无法使用格式化分区
Format-Volume -Partition $partition -FileSystem NTFS
这就是我得到的:
这可能会有所帮助。这是$partition
的内容。如你所见,它没有
Get-Partition
返回CimInstance
类型的对象。所以你可以和Format-Volume
一起使用它。检查文档:https://docs.microsoft.com/en-us/powershell/module/storage/format-volume?view=win10-ps
PS X:\> $partition = get-disk -number 0 | get-partition | Where DriveLetter -eq "D"
PS X:\> $partition.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True CimInstance System.Object
PS X:\> Format-Volume -Partition $partition -FileSystem NTFS