5

Get-Disk コマンドレットを使用するとエラーが発生します

Windows バージョン: Microsoft Windows Server 2008 R2 SP1 64b

Windows 2008 R2 powershell 「Get-Disk」という用語は、コマンドレットの名前として認識されません。Powershell のバージョン 3 を使用しています

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`

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
4

2 に答える 2

7

[コメントを回答に組み合わせて少し追加するだけ]

Get-Diskまた、Azure VM Server 2008 R2 でコマンドを使用することを検討していました。PowerShell 3.0 をインストールしGet-Diskましたが、まだ使用できず、このページにアクセスしました。

このScripting Guy ブログ リンクから、次のことが言及されています。

注 Windows 7 用の Windows PowerShell 3.0 のバージョンには、現時点ではストレージ モジュールが含まれていないため、Windows 8 または Windows Server 2012 が必要です。

Get-Diskそのため、Windows Server 2008 R2 での使用を検討している場合は、できません。

同じ 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
于 2013-02-28T03:59:11.570 に答える
2

ユース ケースによっては、 Win32_Volume クラスを使用して、コマンドレットを使用せずに PowerShell でディスクに関する情報を取得することもできることに注意してください。たとえば、次のようにしてドライブ文字を変更できます。

$drive = gwmi win32_volume -Filter "DriveLetter = 'F:'"
$drive.DriveLetter = "D:"
$drive.Put()
于 2014-02-27T15:31:56.220 に答える