Powershell script replace sc config

3.6k Views Asked by At

Good Day,

i look for a same command as

sc config BITS type= own in Powershell. I think ist with set-service -name BITS -computername server1234 -idon´t know

I have the problem that my INVOKE-COMMAND don´t work. But all scripts work only this line don´t work.

Invoke-Command -ComputerName $serverneedhelp -ScriptBlock {Start-Process cmd -ArgumentList "/c 'sc config bits type= own'"}

If anybody can help me, it is were so great. Thankyou

Greeting Jan

3

There are 3 best solutions below

0
Jan Kraemer On BEST ANSWER

in my script work it with

Invoke-Command -ComputerName $serverneedhelp -ScriptBlock {Start-Process cmd  -ArgumentList "/c sc config bits type= own"}

But I search a version of Powershell without cmd

0
js2010 On

Run it directly?

Invoke-Command $serverneedhelp { sc config bits type= own }

The other alternative is with wmi: Configure service with Set-Service

0
mr00va On

I know that this is old thread, but maybe someone would benefit from this. What worked for me is:

Invoke-Command -ComputerName $serverneedhelp -ScriptBlock {& SC.exe config "bits" type= own}