0

This is a bit of an odd one, but I am trying to figure out how to use sc.exe with variable parameters. Powershell 7.X does not support Set-Service password changes for remote services. However, you can still do so via sc.exe <server> <servicename> obj= "domain\username" password= "whatever".

I am working this into an interactive script, so the remote server, service name, and username will already be in Powershell parameters. However, doing something such as sc.exe \\$server $service obj= "$domain\$username" password= "whatever" does not work. It fails with an unrecognized command error.

I assume this can be done and I am just missing something easy, but any help is appreciated.

sbagnato
  • 603
  • 3
  • 11
  • 35
  • It looks like you're missing the command name, `create` - https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-create – mklement0 Apr 25 '23 at 02:18
  • I am not creating the service though. It already exists. I am just changing the password. – sbagnato Apr 25 '23 at 15:46
  • 1
    Then I assume you need the [`config`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-config) subcommand. – mklement0 Apr 25 '23 at 15:47

0 Answers0