How to run any cmdlet on Windows Server 2012 not under Administrator account?
-
Wednesday, January 30, 2013 12:41 AM
Dear friends,
When I run the following script or similar on w2k12:
Get-PSSessionConfiguration
I'm getting an error:
Get-PSSessionConfiguration : Access is denied. To run this cmdlet, start Windows PowerShell with the "Run as
administrator" option.
At line:1 char:1
+ Get-PSSessionConfiguration
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-PSSessionConfiguration], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetPSSessionConfiguration
CommandWhen I open powershell console using "Run as administrator" everything works fine.
On w2k3 and w2k8 I had the same problem, it was solved performing: Set-ExecutionPolicy Unrestricted; in both PowerShell versions x86 and x64. Then I could run any script under any account.
By now Set-ExecutionPolicy Unrestricted; doesn't solve this problem any more on w2k12. I need to run scripts not under Administrator account. BTW my account belongs to BUILTIN\Administrators group but seems it doesn't helps
Have I missed something? Please help me if you know how to solve this problem.
All Replies
-
Wednesday, January 30, 2013 12:45 AMModerator
Running elevated (right-click, Run as administrator) has nothing to do with execution policy.
Just because your account is a member of the local Administrators group does not mean programs you start run as administrator. To do that, you must manually elevate (right-click, Run as administrator).
Bill
- Edited by Bill_StewartMicrosoft Community Contributor, Moderator Wednesday, January 30, 2013 12:46 AM
-
Wednesday, January 30, 2013 2:13 PM
Bill, thanks for reply.
I found the reason and my problem has been solved.
The thing is UAC (User Account Control) in Windows 8 and Windows Server 2012 doesn't works, when you pull down the slider UAC doesn't turn's off. When you need to Turn Off UAC you have to edit the registry:
Just run PowerShell as Administrator and paste the following to disable UAC:
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0"
shutdown -r -t 0I found solution of this problem here: http://www.neowin.net/forum/topic/1120770-windows-8-run-everything-as-administrator/
I hope it will be helpful for somebody else.
Vitaliy
- Marked As Answer by Explicito Wednesday, January 30, 2013 2:14 PM
-
Wednesday, January 30, 2013 2:17 PM
That has nothing to do with your question or your issue.
What you have done is a very bad idea. You should not disable UAC.
¯\_(ツ)_/¯
-
Wednesday, January 30, 2013 3:13 PMModerator
I agree with jrv. IMO UAC should not be disabled.
Bill

