找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 149|回复: 0

[问题求助] BootPartition=TRUE为啥无输出

[复制链接]
发表于 2026-4-10 05:27:10 | 显示全部楼层 |阅读模式
本帖最后由 小白龙 于 2026-4-10 05:44 编辑

下面的代码, 在我的电脑上有输出(pwsh7), 但是在另一台电脑(powershell5.1)上报后面的错误, 按我的理解, 电脑上不都有启动分区吗?

  1. wmic partition where "BootPartition=TRUE" get Index, DiskIndex, Size, Type
复制代码


错误信息:
wmic : GET 表达式无效。
所在位置 行:2 字符: 1
+ wmic partition where "BootPartition=TRUE" get Index, DiskIndex, Size, ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (GET 表达式无效。:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

------------------------------------------------------------------------------------------------------------------------------------------
好奇怪呀, 下面是测试步骤:
PS C:\Users\Administrator> wmic partition where "BootPartition=TRUE" get Index
Index
0
0

PS C:\Users\Administrator> wmic partition where "BootPartition=TRUE" get Index,DiskIndex
DiskIndex  Index
1          0
0          0

PS C:\Users\Administrator> wmic partition where "BootPartition=TRUE" get Index,DiskIndex,Size
DiskIndex  Index  Size
1          0      64421363712
0          0      85893054464

PS C:\Users\Administrator> wmic partition where "BootPartition=TRUE" get Index,DiskIndex,Size,Type
DiskIndex  Index  Size         Type
1          0      64421363712  Installable File System
0          0      85893054464  Installable File System

PS C:\Users\Administrator> wmic partition where "BootPartition=TRUE" get Index, DiskIndex, Size, Type
GET 表达式无效。

问题已经解决, 这是个大坑, 在powershell5.1中, get后面的必须直接用,不能用空格
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-4-19 17:51

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表