Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Start Automatic Services on Remote machines if stopped

$
0
0

Give this a try:

Get-WmiObject win32_service -Filter "startmode = 'auto' and state != 'running'" -computername (Get-Content C:\ServerList.txt) |
ForEach-Object {
    $result = $_.StartService()
    # You can check the value of $result.ReturnValue here; if it's zero, the service started successfully.
}

Viewing all articles
Browse latest Browse all 13067

Trending Articles