Format disk RAM tanpa huruf drive menggunakan cmdlet `Format-Volume`

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


person SATO Yusuke    schedule 09.05.2020    source sumber
comment
Edit Ulang 2: Ini mencari subtipe CimInstance tertentu, jika Anda mau: MSFT_Volume, seperti yang dilaporkan oleh Get-Volume (nama lengkap tipe ETS adalah Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Volume).   -  person mklement0    schedule 12.05.2020


Jawaban (1)


Saya mengonfirmasi di forum pengguna bahwa ImDisk tidak memiliki antarmuka untuk Volume Mount Manager. Jadi tidak ada cara untuk memformat disk RAM yang dibuat dengan ImDisk dengan Format-Volume cmdlet.

Catatan: Saya juga mencoba memformat disk RAM yang dibuat dengan Dataram RAMDisk. Ini memiliki antarmuka untuk Volume Mount Manager, tetapi Format-Volume -DriveLetter S pada akhirnya memerlukan otoritas administrator.

PS C:\> Format-Volume -DriveLetter S
Format-Volume : Access Denied
Activity ID: {1c815d1b-72f2-4432-b0e1-a33c96d2f539}
At line:1 char:1
+ Format-Volume -DriveLetter S
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Format-Volume], CimExc
   eption
    + FullyQualifiedErrorId : StorageWMI 40001,Format-Volume

Tampaknya cmdlet Format-Volume memerlukan otoritas administrator.

person SATO Yusuke    schedule 18.05.2020