Thursday, June 2, 2016

How to create a RAM disk at system startup using ImDisk


$taskname = "Create RAM disk at startup"

$credential = $Host.UI.PromptForCredential($taskname, "Enter user account information for running this task.", `
    "$env:USERDOMAIN\$env:USERNAME", $env:userdomain)
$username = $credential.UserName
$password = $credential.GetNetworkCredential().Password

$action = New-ScheduledTaskAction -Execute imdisk -Argument '-a -s 1G -m R: -p "/fs:ntfs /v:RAMDISK /q /y"'
$trigger = New-ScheduledTaskTrigger -AtStartup
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskname -RunLevel Highest `
    -User $username -Password $password

No comments:

Post a Comment