Solved

Need Powershell script to check server service status after bulk restart

Posted on 2013-10-30
4
1,063 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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
A hard and fast method for reducing Active Directory Administrators members.
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

739 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