Method invocation failed …doesn’t contain a method named ‘ChangeStartMode’

Execution of following command gives this message: Method invocation failed ….

PS C:..Windows..system32> $srv = gwmi win32_service -computer . | Where-Object {$_.name -like “*browse*”}

PS C:..Windows..system32> $srv.ChangeStartMode(“Disabled”)

Let’s see the methods here

PS > $svc | Get-Member -MemberType method | Format-Table name

—————————
Change
ChangeStartMode
Delete
GetSecurityDescriptor
InterrogateService
PauseService
ResumeService
SetSecurityDescriptor
StartService
StopService
UserControlService
——————————

The method is there. THEN where is the problem.

The problem is that gwmi win32_service -computer . | Where-Object {$_.name -like “*browse*”} returns two services and both can’t be disabled in this manner.

Now try this
PS C:..Windows..system32> $srv = gwmi win32_service -computer . | Where-Object {$_.displayname -like “*sql*browse*”}
PS C:..Windows..system32> $srv.ChangeStartMode(“Automatic”)

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0

Return value 0 means the operation is successful.

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

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