Does anyone have a Powershell script to change the credentials used by a Windows service?
In Powershell, we can change Windows Service Account username and password using WMI based powershell cmdlet Get-WmiObject and the WMI class Win32_Service. You can even easily change Service account infromation in Remote Computer.
$cred = Get-Credential without asking for prompts in powershell - Microsoft Tech Community.
Open the Services snapin by executing services. msc . Find the PowerShell Universal service and right click it and then click Properties. Click the Log On tab and enter the credentials for the service account.
Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and find the subkey with your service's name. Right-click the key you found in step #3, and select Rename. Enter the new name for the service. Restart the computer.
Bit easier - use WMI.
$service = gwmi win32_service -computer [computername] -filter "name='whatever'" $service.change($null,$null,$null,$null,$null,$null,$null,"P@ssw0rd")
Change the service name appropriately in the filter; set the remote computer name appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With