【问题标题】:Removable media holding D drive letter持有 D 盘符的可移动媒体
【发布时间】:2020-03-03 17:49:33
【问题描述】:

我的系统上有一些 SD 卡或可移动媒体驱动器,默认情况下使用 D 驱动器号。

我有这个:

PS C:\Windows\System32\WindowsPowerShell\v1.0> get-volume | where DriveType -Match "Removable"

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus SizeRemaining Size
----------- --------------- ---------- --------- ------------ ------------- ----
E                                      Removable Healthy                0 B  0 B

我想像这样把它改成 G:

PS C:\Windows\System32\WindowsPowerShell\v1.0> get-volume | where DriveType -Match "Removable" |Set-Partition -NewDriveLetter G

但我明白了:

Set-Partition : 传递给方法的一个或多个参数值无效。 在行:1 字符:50 + ... |其中 DriveType -匹配“可移动”|Set-Partition -NewDriveLetter G + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (PS_StorageCmdlets:ROOT/Microsoft/..._StorageCmdlets) [Set-Partition], 异常 +fullyQualifiedErrorId : MI RESULT 4,Set-Partition

我该如何改变呢?或者是什么问题?我尝试使用 get-disk 来通过,但也不起作用。 我可以在计算机管理 gui 中进行更改,但我需要命令行。

【问题讨论】:

    标签: windows powershell scripting


    【解决方案1】:

    你应该可以用这样的东西来做到这一点。

    $DriveLetter = (Get-Volume | Where-Object {$_.DriveType -eq "Removable"}).DriveLetter
    Get-Partition -DriveLetter $DriveLetter | Set-Partition -NewDriveLetter G
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-07
      • 1970-01-01
      • 2019-04-10
      • 2012-07-20
      • 2020-02-08
      相关资源
      最近更新 更多