I’ve read this article, OS Hub – Creating In-Memory RAM Drive on Windows Server, on creating a RAM Drive for Windows Server using PowerShell (which is perfect when handling sensitive data temporarily that requires a file path).
But since Windows 10 can’t act as an iSCSI Provider with native tools, that won’t work.
# Install the features
Install-WindowsFeature -Name FS-FileServer
Install-WindowsFeature -Name FS-iSCSITarget-Server
Start-Service MSiSCSI
# Open local firewall if necessary
Set-NetFirewallRule -Name MsiScsi-in-TCP -Enabled True
Set-NetFirewallRule -Name MsiScsi-out-TCP -Enabled True
# Allow iSCSI LoopBack
Set-ItemProperty -Path 'HKLM:SOFTWAREMicrosoftiSCSI Target' -Name AllowLoopBack -Value 1
# Setup an iSCSI disk
New-IscsiVirtualDisk -Path 'ramdisk:testRAM.vhdx' -Size 100MB
New-IscsiServerTarget -TargetName targetRAMDisk -InitiatorIds @("IPAddress:<YOUR-IP-HERE>")
Add-IscsiVirtualDiskTargetMapping -TargetName targetRAMDisk -DevicePath "ramdisk:testRAM.vhdx"
Get-IscsiTarget | Connect-IscsiTarget #! Non is found before they are discovered :/
# Format the drive
Get-Disk | where PartitionStyle -eq 'raw' |
Initialize-Disk -PartitionStyle MBR -PassThru |
New-Partition -AssignDriveLetter -UseMaximumSize |
Format-Volume -FileSystem NTFS -NewFileSystemLabel 'RAMdisk' -Confirm:$false
According to the article, your remove the disk on a Windows Server using
Remove-IscsiVirtualDiskTargetMapping -TargetName targetRAMDisk -DevicePath "ramdisk:testRAM.vhdx"
Remove-IscsiServerTarget -TargetName targetRAMDisk
Remove-IscsiVirtualDisk -Path "ramdisk:testRAM.vhdx"
So, any takes on other methods of creating RAM Drives using PowerShell that will work with Windows 10/11?
Maybe there is even a C# implementation available of Windows 2000 Ramdisk.sys (KB257405) available somewhere that could be adopted for PowerShell?