Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell: Permanently Modify Path, "Requested registry access is not allowed."

I need to permanently add a scripts folder to my PowerShell path (not just a particular session). I am running the following code:

[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\scripts", "Machine")

The error is as follows:

Exception calling "SetEnvironmentVariable" with "3" argument(s): "Requested registry access is not allowed."

How do I get registry access/fix this?

EDIT: Not sure if it helps, but I'm using PowerCLI (VMware PowerShell API) on Windows Server 2012.

like image 475
corneria Avatar asked Nov 20 '13 21:11

corneria


1 Answers

It sounds like you might not be running as an elevated admin. By default, I believe there's a PowerShell shortcut on your taskbar in Server 2012. Right-click on it, and choose "Run as Administrator" (or something like that). Then try running the command in your original post.

like image 157
mikekol Avatar answered Sep 22 '22 00:09

mikekol