Powershell script to change service account

前端 未结 10 2430
小蘑菇
小蘑菇 2020-12-15 03:07

Does anyone have a Powershell script to change the credentials used by a Windows service?

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 03:38

    $svc = Get-WmiObject win32_service -filter "name='serviceName'"
    

    the position of username and password can change so try this line to find the right place$svc.GetMethodParameters("change")

    $svc.change($null,$null,$null,$null,$null,$null,$null,$null,$null,"admin-username","admin-password")
    

提交回复
热议问题