I’ve built scripts that just do a simple restart or stop/start action, but my question is can i do a script that i can run from my desktop that will restart a service remotely on another machine. I’m guessing there’s a way just dont know what to add to the script.

7 Spice ups

yes.

sc \machine stop

4 Spice ups

Have you taken a look at Spiceworks troubleshooting feature? It allows you to view hardware states, services, and processes.

also via powershell:

get-service -computername YOURSERVER -displayname "Spiceworks" | start-service
1 Spice up

yes, use Powershell remoting like:

Invoke-Command -ComputerName RemoteComputerName { Restart-Service -Name Spooler -Force }

The remote computer must be running WinRM, and you must have sufficient permissions. Windows 8 and above and Server 2012 and above come with WinRM by default.

and from powershell:

Get-Service -Name bits -ComputerName RSLAPTOP01 | Set-Service -Status Running

Or use the services snap in to restart them on the remote computer

1 Spice up

Yes you can do that. You will have to do a remote admin privilege and then connect to the computer using powershell then do the stop, start or restart as needed.

And psremoting needs to be enabled - is psremoting enabled by default? I know winRM is installed, but enabled?

Thanks for all the PS replies guys but i do prefer bat files for some reason.

So if i just do a restart insteadof stop? or do I have to do a stop, pause, start?

1 Spice up

stop then start = restart

Seriously, you need to step away from batch files. That is the way of the past, and honestly, if you don’t know PS, you’ll have a hard time in the job market for Windows admin roles.

2 Spice ups

Restart didnt work…I’ll try again.

I use PS for more complex stuff but for simple stuff like this i just prefer batch files, less problems usually.

And no troubles w/ the job market bud, I’m doing just fine :wink:

2 Spice ups

sc \machinename service stop

sc \machinename service start

:wink:

1 Spice up

sc \machine stop

Ha! So says everyone. I didn’t mean to make an assumption, but just saying - - - you might change your mind about your job in the future. I know I did.

1 Spice up

I hear you man, you’re always happy till you’re not LOL

I do enjoy powershell, and again use it for some more complex stuff, I wouldnt call myself a PS expert by any means, but I do still like bat for the small stuff.

1 Spice up

You can also do this in Spiceworks

If you want to see PS happiness, come to SpiceWorld 2014 and attend Robs session! I learn something new every year from this guy!