Powershell script to change service account

Issue

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

Solution

Bit easier – use WMI.

$service = gwmi win32_service -computer [computername] -filter "name='whatever'"
$service.change($null,$null,$null,$null,$null,$null,$null,"[email protected]")

Change the service name appropriately in the filter; set the remote computer name appropriately.

Answered By – Don Jones

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published