Solved

Need Powershell script to check server service status after bulk restart

Posted on 2013-10-30
4
1,087 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39611109
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 8

Author Comment

by:Senior IT System Engineer
ID: 39611117
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
ID: 39611150
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 8

Author Closing Comment

by:Senior IT System Engineer
ID: 39626456
Thsank !
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses

628 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