i am trying to use a powershell script that allows me to change the user account and password a specific service runs under.

$account="domain\account"
$password="password"

$svc=gwmi win32_service -filter "name='MyService'"
$svc.change($null,$null,$null,$null,$null,$false,$account,$password,$null,$null,$null)

I could check that the account was changed but when i tried to run the service from the Service.msc GUI it fails with a logon failure.

If I use to start the service from the script itself i get the following error.

$svc.StartService()



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

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

According to microsoft it is a logon error : Return Value 15.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384901%28v=vs.85%29.aspx

I have verified the password a millions time and when I copy and paste the password using the GUI it just works.

May be i am missing something in my script. (SecurityPolicy is unrestricted on this machine)

Edit
Report