Latar belakang
Saya memiliki disk RAM yang dibuat dengan ImDisk Toolkit. Huruf drive-nya adalah "R". Saya dapat mengakses disk RAM dengan benar (Get-ChildItem R:
menunjukkan entri direktori dengan benar).
Saya ingin memformat disk RAM di skrip PowerShell saya (menjalankan benchmark) tanpa otoritas administrator. Jadi saya tidak ingin menggunakan perintah format
karena memerlukan otoritas administrator untuk menjalankannya.
Masalah
Ketika saya mencoba memformat disk RAM dengan Format-Volume
cmdlet PowerShell, saya mendapatkan kesalahan berikut:
PS C:\> Format-Volume -DriveLetter R
Format-Volume : No MSFT_Volume objects found with property 'DriveLetter' equal to 'R'. Verify the value of the
property and retry.
At line:1 char:1
+ Format-Volume -DriveLetter R
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (R:Char) [Format-Volume], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound_DriveLetter,Format-Volume
Dan saya menemukan disk RAM sepertinya tidak memiliki huruf drive dari PowerShell (dengan Get-Volume
).
DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size
----------- ------------ -------------- --------- ------------ ----------------- ------------- ----
E Unknown Fixed Healthy Unknown 0 B 0 B
C Windows NTFS Fixed Healthy OK 334.99 GB 475.7 GB
Windows RE tools NTFS Fixed Healthy OK 504.46 MB 990 MB
Saya telah mencoba memilih disk RAM dengan properti FriendlyName
, tetapi saya tidak dapat mengakses properti itu. FriendlyName
tampaknya bukan properti sebenarnya (tidak terdaftar dengan Get-Member
). Jadi saya tidak bisa memfilter hasil Get-Volume
dan meneruskannya ke Format-Volume
.
Pertanyaan
Bagaimana cara menentukan disk RAM untuk diformat dengan Format-Volume
cmdlet yang tampaknya tidak memiliki huruf drive dengan Get-Volume
? Atau, apakah saya harus menggunakan perintah format
daripada Format-Volume
cmdlet (jadi saya harus memiliki otoritas administrator) dalam situasi ini?
Sunting
Saya menemukan disk RAM tidak muncul di hasil Get-Volume
, Get-CimInstance Win32_Volume
atau Get-CimInstance Win32_DiskPartition
. Hanya muncul di hasil Get-CimInstance Win32_LogicalDisk
seperti ini:
PS C:\> Get-CimInstance Win32_LogicalDisk
DeviceID DriveType ProviderName VolumeName Size FreeSpace
-------- --------- ------------ ---------- ---- ---------
C: 3 Windows 510781288448 353026121728
E: 3
R: 3 1073737728 1056030720
Z: 3 3897664995328 3646232199168
Perhatikan bahwa disk RAM (R:) ditampilkan sebagai DriveType 3
(Disk tetap).
Saya bisa mendapatkan objek dari disk RAM (R :), tetapi saya mendapat kesalahan berikut dengan Format-Volume
.
PS C:\> $ramDisk = Get-CimInstance Win32_LogicalDisk | Where-Object { $_.DeviceID -eq "R:" }
PS C:\> Format-Volume -Partition $ramDisk -WhatIf
Format-Volume : Cannot bind argument to parameter 'Partition', because PSTypeNames of the argument do not match the
PSTypeName required by the parameter: Microsoft.Management.Infrastructure.CimInstance#MSFT_Partition.
At line:1 char:26
+ Format-Volume -Partition $ramDisk -WhatIf
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Format-Volume], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : MismatchedPSTypeName,Format-Volume
Sunting 2
Format-Volume -InputObject
juga mengembalikan kesalahan berikut.
PS C:\> $ramDisk = Get-CimInstance Win32_LogicalDisk | Where DeviceId -eq 'R:'
PS C:\> $ramDisk
DeviceID DriveType ProviderName VolumeName Size FreeSpace
-------- --------- ------------ ---------- ---- ---------
R: 3 1073737728 1056030720
PS C:\> Format-Volume -InputObject $ramDisk -WhatIf
Format-Volume : Cannot bind argument to parameter 'InputObject', because PSTypeNames of the argument do not match the P
STypeName required by the parameter: Microsoft.Management.Infrastructure.CimInstance#MSFT_Volume.
At line:1 char:28
+ Format-Volume -InputObject $ramDisk -WhatIf
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Format-Volume], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : MismatchedPSTypeName,Format-Volume
CimInstance
tertentu, jika Anda mau:MSFT_Volume
, seperti yang dilaporkan olehGet-Volume
(nama lengkap tipe ETS adalahMicrosoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Volume
). - person mklement0   schedule 12.05.2020