![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | stopping and starting service I am new to powershell and I was wondering if there is a way I can use powershell to notify me when a particular service on a server has stopped. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: stopping and starting service The short answer is yes, but to be honest it is not the right tool for the that job. Long Answer, If you want to monitor Process,Mem,Service or pretty much anything you want a persistent application running that goes off in timed intervals. In this case a Service is really a better option. If you want to use Powershel then something like this while($true) { if((Get-WmiObject Win32_service | where{$_.name -match $service}).State -ne "Running") { #Do notification of choice } } Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject m> I am new to powershell and I was wondering if there is a way I can m> use powershell to notify me when a particular service on a server has m> stopped. m> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: stopping and starting service Marco pointed out that I forgot a sleep statement Without this would looppretty fast ![]() while($true) { if((Get-WmiObject Win32_service | where{$_.name -match $service}).State -ne "Running") { #Do notification of choice } start-sleep 300 # 5 Min } Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject BS> The short answer is yes, but to be honest it is not the right tool BS> for the that job. BS> BS> Long Answer, If you want to monitor Process,Mem,Service or pretty BS> much anything you want a persistent application running that goes BS> off in timed intervals. In this case a Service is really a better BS> option. BS> BS> If you want to use Powershel then something like this BS> BS> while($true) BS> { BS> if((Get-WmiObject Win32_service | where{$_.name -match BS> $service}).State BS> -ne "Running") BS> { BS> #Do notification of choice BS> } BS> } BS> Brandon Shell BS> --------------- BS> Blog: http://www.bsonposh.com/ BS> PSH Scripts Project: www.codeplex.com/psobject m>> I am new to powershell and I was wondering if there is a way I can m>> use powershell to notify me when a particular service on a server m>> has stopped. m>> |
My System Specs![]() |
| | #4 (permalink) |
| | Re: stopping and starting service Brandon Shell [MVP] wrote: Quote: > The short answer is yes, but to be honest it is not the right tool for > the that job. > > Long Answer, If you want to monitor Process,Mem,Service or pretty much > anything you want a persistent application running that goes off in > timed intervals. In this case a Service is really a better option. > > If you want to use Powershel then something like this > > while($true) > { > if((Get-WmiObject Win32_service | where{$_.name -match > $service}).State -ne "Running") > { > #Do notification of choice > } > } http://mow001.blogspot.com/2005/11/s...-from-msh.html "Monad" was the original "codename" for PowerShell. Some things will still work as is with the current PowerShell version. You can also set up a balloon tip: http://blog.sapien.com/current/2007/...owershell.html Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #5 (permalink) |
| | RE: stopping and starting service If it's a 2003 server, you should be able to use a Powershell script to send you an email notification, and the options on the services Recovery tab to invoke the script if the service fails. "maquinaloca" wrote: Quote: > I am new to powershell and I was wondering if there is a way I can use > powershell to notify me when a particular service on a server has stopped. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: stopping and starting service "Rob Campbell" <RobCampbell@xxxxxx> wrote in message news:E83C1770-07DE-4FAD-8698-2663D5D42081@xxxxxx Quote: > If it's a 2003 server, you should be able to use a Powershell script to > send > you an email notification, and the options on the services Recovery tab to > invoke the script if the service fails. > > "maquinaloca" wrote: > Quote: >> I am new to powershell and I was wondering if there is a way I can use >> powershell to notify me when a particular service on a server has >> stopped. EventTrigger to start a program (custom, powershell, etc). Writting a (new) service would likely be overkill for this, and Powershell is just one of the choices for responding to such events. -- Herb Martin, MCSE, MVP http://www.LearnQuick.Com (phone on web site) If you use LinkedIn then tell me where you know me from when linking: http://www.linkedin.com/in/herbmartin |
My System Specs![]() |
| | #7 (permalink) |
| | Re: stopping and starting service I agree... this is a great idea. Only caveat would be all servers need powershell installed. "Herb Martin" <news@xxxxxx> wrote in message news:%2312OxbpEIHA.4400@xxxxxx Quote: > > "Rob Campbell" <RobCampbell@xxxxxx> wrote in message > news:E83C1770-07DE-4FAD-8698-2663D5D42081@xxxxxx Quote: >> If it's a 2003 server, you should be able to use a Powershell script to >> send >> you an email notification, and the options on the services Recovery tab >> to >> invoke the script if the service fails. >> >> "maquinaloca" wrote: >> Quote: >>> I am new to powershell and I was wondering if there is a way I can use >>> powershell to notify me when a particular service on a server has >>> stopped. > This is the right way to "think" about this. Use the Service options OR > an > EventTrigger to start a program (custom, powershell, etc). > > Writting a (new) service would likely be overkill for this, and Powershell > is > just one of the choices for responding to such events. > > > -- > Herb Martin, MCSE, MVP > http://www.LearnQuick.Com (phone on web site) > > If you use LinkedIn then tell me where you know me from when linking: > > http://www.linkedin.com/in/herbmartin > > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: stopping and starting service "Brandon Shell [MVP]" <a_bshell@xxxxxx> wrote in message news:BC656C20-24BD-4C3E-982A-7E661DFB1986@xxxxxx Quote: >I agree... this is a great idea. Only caveat would be all servers need >powershell installed. Powershell is only one way to respond (and perhaps not the best one for eveyrone.) Simple batch or even a custom program might be preferable since EventTriggers can call any of these when the event occurs. -- Herb Martin, MCSE, MVP http://www.LearnQuick.Com (phone on web site) If you use LinkedIn then tell me where you know me from when linking: http://www.linkedin.com/in/herbmartin Quote: > "Herb Martin" <news@xxxxxx> wrote in message > news:%2312OxbpEIHA.4400@xxxxxx Quote: >> >> "Rob Campbell" <RobCampbell@xxxxxx> wrote in message >> news:E83C1770-07DE-4FAD-8698-2663D5D42081@xxxxxx Quote: >>> If it's a 2003 server, you should be able to use a Powershell script to >>> send >>> you an email notification, and the options on the services Recovery tab >>> to >>> invoke the script if the service fails. >>> >>> "maquinaloca" wrote: >>> >>>> I am new to powershell and I was wondering if there is a way I can use >>>> powershell to notify me when a particular service on a server has >>>> stopped. >> This is the right way to "think" about this. Use the Service options OR >> an >> EventTrigger to start a program (custom, powershell, etc). >> >> Writting a (new) service would likely be overkill for this, and >> Powershell is >> just one of the choices for responding to such events. >> >> >> -- >> Herb Martin, MCSE, MVP >> http://www.LearnQuick.Com (phone on web site) >> >> If you use LinkedIn then tell me where you know me from when linking: >> >> http://www.linkedin.com/in/herbmartin >> >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| On-line Video playback stopping & starting | Media Center | |||
| Self starting and stopping torrent software | Software | |||
| Starting & stopping services | VB Script | |||
| stopping a program from starting up | Vista General | |||
| Stopping and Starting Audio Service in Vista | Vista General | |||