stop-computer : Privilege not held

3

I am running Powershell (v4) on a Windows7 box ; I was able to until yesterday (2017-04-12) to issue a 'stop-computer' command to shutdown my computer.

Today: I am unable to do so; I get this response: ('zaphod' is the hostname):

 PS C:\Windows\system32> stop-computer
 stop-computer : Privilege not held.
 At line:1 char:1
 + stop-computer
 + ~~~~~~~~~~~~~
     + CategoryInfo          : InvalidOperation: (zaphod:String) [Stop-Computer], ManagementException
     + FullyQualifiedErrorId : StopComputerException,Microsoft.PowerShell.Commands.StopComputerCommand

This happens when I start Powershell with non-admin permissions; or if I use 'Run as Administrator' (and it is running as Administator ; since I get the "User Account Control' popup when I do this).

There were some automatic Windows Updates made to my machine today - maybe these are somehow responsible ?

Oddly; 'restart-computer' does work.

Is this a known thing ? Can I get my permissions back somehow ?

More research follows:

EDIT: if I issue the command with the '-asjob' flag - it does work:

stop-computer -asjob # this works !

I issued the following command to get help:

get-help Stop-Computer -full

The 'Authentication' Flag is defined as follows:

Authentication <AuthenticationLevel>
   Specifies the authentication level that is used for the  WMI connection. (Stop-Computer uses WMI.) The default
   value is Packet.

   Valid values are:

   Unchanged:       The authentication level is the same as the previous command.
   Default:         Windows Authentication.
   None:            No COM authentication.
   Connect:         Connect-level COM authentication.
   Call:            Call-level COM authentication.
   Packet:          Packet-level COM authentication.
   PacketIntegrity: Packet Integrity-level COM authentication.
   PacketPrivacy:   Packet Privacy-level COM authentication.
   [...]

So confusingly the 'default' Authentication is apparently 'Packet'; but the flag to switch to 'Windows Authentication' is called 'Default'.

In any case; none of the flags allow me to shutdown the computer. I get a slight variation of the error when I use "None":

stop-computer : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At line:1 char:1
+ stop-computer -Authentication None
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Stop-Computer], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.StopComputerCommand

I also switched on tracing using:

Set-PSDebug -Trace 2

Now I get this ; but I don't know what to make of it:

DEBUG:    1+  >>>> stop-computer
DEBUG:     ! CALL function '<ScriptBlock>'
DEBUG:   19+                                         if ( &  >>>> { Set-StrictMode -Version 1; $_.PSMessageDetails } )
{
DEBUG:     ! CALL function '<ScriptBlock>'
DEBUG:   19+                                         if ( & {  >>>> Set-StrictMode -Version 1; $_.PSMessageDetails } )
{
DEBUG:   19+                                         if ( & { Set-StrictMode -Version 1;  >>>> $_.PSMessageDetails } )
{
DEBUG:    1+ &  >>>> { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG:     ! CALL function '<ScriptBlock>'
DEBUG:    1+ & {  >>>> Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
DEBUG:    1+ & { Set-StrictMode -Version 1;  >>>> $this.Exception.InnerException.PSMessageDetails }
DEBUG:    1+ & { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails  >>>> }
DEBUG:   19+                                         if ( & { Set-StrictMode -Version 1; $_.PSMessageDetails  >>>> } )
{
DEBUG:   26+                                         $errorCategoryMsg = &  >>>> { Set-StrictMode -Version 1;
$_.ErrorCategory_Message }
DEBUG:     ! CALL function '<ScriptBlock>'
DEBUG:   26+                                         $errorCategoryMsg = & {  >>>> Set-StrictMode -Version 1;
$_.ErrorCategory_Message }
DEBUG:   26+                                         $errorCategoryMsg = & { Set-StrictMode -Version 1;  >>>>
$_.ErrorCategory_Message }
DEBUG:   26+                                         $errorCategoryMsg = & { Set-StrictMode -Version 1;
$_.ErrorCategory_Message  >>>> }
DEBUG:   42+                                         $originInfo = &  >>>> { Set-StrictMode -Version 1; $_.OriginInfo }
DEBUG:     ! CALL function '<ScriptBlock>'
DEBUG:   42+                                         $originInfo = & {  >>>> Set-StrictMode -Version 1; $_.OriginInfo }
DEBUG:   42+                                         $originInfo = & { Set-StrictMode -Version 1;  >>>> $_.OriginInfo }
DEBUG:   42+                                         $originInfo = & { Set-StrictMode -Version 1; $_.OriginInfo  >>>> }
stop-computer : Privilege not held.
windows-7
powershell-4.0
asked on Super User Apr 13, 2017 by monojohnny • edited Apr 13, 2017 by monojohnny

2 Answers

3

Somebody from Microsoft posted on the Powershell Subreddit about this.

He explains that it is probably a regression bug from the Security and Quality Rollup for the .NET Framework 4.6 and 4.6.1 patch.

You've already found the suggested workaround to use -asjob.

answered on Super User Apr 18, 2017 by Brian Finn • edited Apr 18, 2017 by Michael Frank
1

User contributions licensed under CC BY-SA 3.0