Method invocation failed because [System.ServiceProcess.ServiceController] doesn’t contain a method named

“Method invocation failed because [System.ServiceProcess.ServiceController] doesn’t contain a method named”

INTERVIEW PREPARATION IN 30 MINs – Read Following wires for a quick interview preparation.

  1. SQL Server DBA “Interview Questions And Answers”
  2. SQL Azure Interview Questions and Answers Part – 1
  3. SQL Azure Interview Questions and Answers Part – 2
  4. Powershell Interview Questions and Answers

This message is thrown when you don’t have authentication to run the PS command. Run the PS command as an admin and that would work.

Stop and start service using Powershell command:

PS C:\Users\system> (get-service|Where-Object {$_.name -like “*mssqlserver”}).
stopservice()
Method invocation failed because [System.ServiceProcess.ServiceController] doesn’t contain a method named ‘stopservice’.
At line:1 char:70
+ (get-service|Where-Object {$_.name -like “*mssqlserver”}).stopservice <<<< ()
    + CategoryInfo          : InvalidOperation: (stopservice:String) [], Runti
   meException
    + FullyQualifiedErrorId : MethodNotFound

Running PS as an admin:

PS C:\Windows\system32> get-service|Where-Object {$_.name -like “*mssqlserver”}

Status   Name               DisplayName
——   —-               ———–
Stopped  MSSQLSERVER        SQL Server (MSSQLSERVER)

PS C:\Windows\system32> (get-service|Where-Object {$_.name -like “*mssqlserver”}).start()
PS C:\Windows\system32> get-service|Where-Object {$_.name -like “*mssqlserver”}

Status   Name               DisplayName
——   —-               ———–
Start… MSSQLSERVER        SQL Server (MSSQLSERVER)

PS C:\Windows\system32> get-service|Where-Object {$_.name -like “*mssqlserver”}

Status   Name               DisplayName
——   —-               ———–
Running  MSSQLSERVER        SQL Server (MSSQLSERVER)

Regards,
Online Powershell Classes @ http://tuitionaffordable.webstarts.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s