[英]Windows 2008 R2 powershell The term 'Get-Disk' is not recognized as the name of a cmdlet
I am getting an error when using Get-Disk cmdlet 使用Get-Disk cmdlet时出错
Windows version: Microsoft Windows Server 2008 R2 SP1 64b Windows版本:Microsoft Windows Server 2008 R2 SP1 64b
Windows 2008 R2 powershell The term 'Get-Disk' is not recognized as the name of a cmdlet. Windows 2008 R2 powershell术语“Get-Disk”无法识别为cmdlet的名称。 I have version 3 of Powershell
我有Powershell的第3版
PS C:\\Windows\\system32> Get-Disk
PS C:\\ Windows \\ system32> Get-Disk
Get-Disk : The term 'Get-Disk' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ Get-Disk
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Disk:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\\Windows\\system32> $PSVersionTable`
PS C:\\ Windows \\ system32> $ PSVersionTable`
Name Value
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.1
PSRemotingProtocolVersion 2.2
[Just combining the comments into an answer and added a bit] [只是将评论结合到答案中并添加了一点]
I also was looking to use the Get-Disk
command on an Azure VM Server 2008 R2, I installed PowerShell 3.0 and Get-Disk
was still not available, and then googled to this page. 我还希望在Azure VM Server 2008 R2上使用
Get-Disk
命令,我安装的PowerShell 3.0和Get-Disk
仍然不可用,然后用Google搜索到此页面。
From this Scripting Guy blog link it mentions that 从这篇Scripting Guy博客链接中可以看出这一点
Note The version of Windows PowerShell 3.0 for Windows 7 does not contain the Storage module at this time, so Windows 8 or Windows Server 2012 is a requirement.
注意Windows PowerShell 3.0 for Windows 7的版本目前不包含存储模块,因此需要Windows 8或Windows Server 2012。
So if your looking to use Get-Disk
on Windows Server 2008 R2, you cant. 因此,如果您希望在Windows Server 2008 R2上使用
Get-Disk
,那么您无法做到。
The same Scripting Guy link also provides the relevant DiskPart commands that can be used instead. 相同的Scripting Guy链接还提供了可以使用的相关DiskPart命令。
From an elevated shell:
DiskPart.exe
List disk
Select disk 1—disk 1 being the USB drive
Clean
Create partition primary
Select partition 1—partition 1 being the new partition
Active
Format FS=NTFS
Depending on your use case, note that you can also get information on the disk in powershell without using a cmdlet, using the Win32_Volume class For example, you could do the following to change the drive letter: 根据您的使用情况,请注意您还可以使用Win32_Volume类在不使用cmdlet的情况下获取PowerShell中的磁盘信息。例如,您可以执行以下操作来更改驱动器号:
$drive = gwmi win32_volume -Filter "DriveLetter = 'F:'"
$drive.DriveLetter = "D:"
$drive.Put()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.