Solved

Need Powershell script to check server service status after bulk restart

Posted on 2013-10-30
4
1,002 Views
Last Modified: 2013-11-05
Hi People,

Can anyone please assist me with the Powershell script to report any service that is not running eg. (Startup Mode Automatic but Status is Stopped after the server reboot) ?

the input is from a .CSV with the list of the server in one column only.

the result is server name and stopped service name.
0
Comment
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
Try..
GC C:\server.txt | % {
Get-WmiObject win32_service -Filter "startmode = 'auto' AND state != 'running'" -ComputerName $_ | 
	Select SystemName,DisplayName,StartName,State
} | Export-Csv C:\service.csv -NTI

Open in new window

C:\server.txt format..
ServerA
ServerB
ServerC

Open in new window

0
 
LVL 7

Author Comment

by:Senior IT System Engineer
Comment Utility
Cool, thanks for the quick reply Subsun.

So in this case if the server is not joined to the domain or just a workgroup server, my power shell session as domain admin won't work.

Is there any way to retry the login using local admin password in case first attempt to login with domain admin failed ?
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
You can try adding -credential parameter to Get-WmiObject command... Check with single computer and see if it works..

 
$cred = get-Credential
Get-WmiObject win32_service -Filter "startmode = 'auto' AND state != 'running'" -ComputerName ServerA -credential $cred

Open in new window

0
 
LVL 7

Author Closing Comment

by:Senior IT System Engineer
Comment Utility
Thsank !
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now