locked
How to run any cmdlet on Windows Server 2012 not under Administrator account? RRS feed

  • Question

  • 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
       Command

    When 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.

    Wednesday, January 30, 2013 12:41 AM

Answers

  • 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 0
     

    I 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:13 PM

All replies

  • 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

    Wednesday, January 30, 2013 12:45 AM
  • 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 0
     

    I 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:13 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 2:17 PM
  • I agree with jrv. IMO UAC should not be disabled.

    Bill

    Wednesday, January 30, 2013 3:13 PM
  • A safer bet would be to configure 'trusted hosts' on the server you want to remote onto.  This means you can remote execute commands on a Server 2012, Win8, or anything with PS3 without completely disabling UAC.

    Saturday, June 8, 2013 10:51 AM