Created
August 29, 2022 18:33
-
-
Save aimerneige/cb738f6da37db86c247db7fda12deb15 to your computer and use it in GitHub Desktop.
ramdisk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (Get-ScheduledTask -TaskName "RamDisk" -ErrorAction SilentlyContinue) { | |
| Write-Host "Ramdisk Task schduler already configured." -ForegroundColor Green | |
| } else { | |
| Write-Host "Configuring task scheduler to start Ramdisk in the background..." -ForegroundColor Green | |
| Set-Content -Path "$env:APPDATA\ramdisk.cmd" -Value "`"C:\Program Files\OSFMount\osfmount.com`" -a -t vm -o format:ntfs:`"RAM Volume`" -o physical -o gpt -s 4G" | |
| $taskAction = New-ScheduledTaskAction -Execute "$env:APPDATA\ramdisk.cmd" | |
| $trigger = New-ScheduledTaskTrigger -AtLogOn | |
| $principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserId (Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -expand UserName) | |
| $settings = New-ScheduledTaskSettingsSet –AllowStartIfOnBatteries –DontStopIfGoingOnBatteries -Hidden -ExecutionTimeLimit (New-TimeSpan -Minutes 5) -RestartCount 3 | |
| Register-ScheduledTask -Action $taskAction -Trigger $trigger -TaskName "RamDisk" -Description "Start ramdisk in the background." -Settings $settings -Principal $principal | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This powershell script helps you to create a 4G ramdisk every time you start your computer.