Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell start specific automatic services

$
0
0

Hello,

I have some services that i first need to start and than stop again. But if those services are automatic it should start again.

Can somebody help me with finding this script.

It only needs to check on specific services !

If 1 of these services are automatic than powershell needs to start them: 

So what i already got is:

Start-Service d1
Start-Service d2
Start-Service d3
Start-Service d4
Start-Service d5
Start-Service d6
Start-Service d7

Stop-Service d1
Stop-Service d2
Stop-Service d3
Stop-Service d4
Stop-Service d5
Stop-Service d6
Stop-Service d7

I am thinking about this but it is not working:

$NameSrv = 'd1'
$Service = Get-WmiObject win32_service -filter "NAME = '$NameSrv'
If ($Service.Startmode -eq "Automatic") {
Start-Service = $NameSrv

But it is not working 


Please help me.

Regards,

Dirk 



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>