Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need Powershell script to check server service status after bulk restart

Posted on 2013-10-30
4
Medium Priority
?
1,139 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
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 2000 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

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Question has a verified solution.

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

How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

824 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