If you need to start a stopped service across a batch of machines — as opposed to restarting a service that’s already running — the approach is nearly identical to restarting one, just swapping Restart-Service for a status check plus Start-Service.
The script
Create a plain text file listing the target device names (NETBIOS names, one per line), then run this from an elevated PowerShell prompt:
$Servers = Get-Content C:\TGH\serverlist.txt
Invoke-Command -ComputerName $Servers -ScriptBlock
{
if ((Get-Service -Name spooler).Status -ne "Running")
{
Start-Service -Name spooler
}
}
What to change
C:\TGH\serverlist.txt— the path to your device list. You can populate this manually, or generate it from an Active Directory export or an SCCM collection query exported to a text file.spooler— the service name (not the display name) you want to check and start. UseGet-Service | Select-Object Name, DisplayNameon a reference machine if you’re not sure of the correct service name — for example, the Print Spooler’s display name is “Print Spooler” but its actual service name isspooler.
The status check inside the script block means this is safe to run repeatedly — machines where the service is already running are simply skipped, so you don’t need to pre-filter your device list to only include machines where the service is currently stopped.
Invoke-Command requires PowerShell remoting to be enabled on the target machines (Enable-PSRemoting) and appropriate permissions for the account running the script.
Resources
Gear We Recommend
Testing configs is easier with a dedicated admin machine set up right. Here’s the kit we use.
Browse our Windows Admin Toolkit picks on AmazonAs an Amazon Associate, TechyGeeksHome earns from qualifying purchases.
Discover more from TechyGeeksHome
Subscribe to get the latest posts sent to your email.