Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need Powershell script to check server service status after bulk restart

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
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.
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

715 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