Disclaimer
This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

Get service info remotely using alternate admin credentials (Powershell)

*** THIS SCRIPT IS PROVIDED WITHOUT WARRANTY, USE AT YOUR OWN RISK ***

This script will allow you to read a list of computers from the computers.txt file and use alternate admin credentials to get service information remotely. The script contains a few examples, cut and paste as you wish.

Tested on Windows Server 2K3, Windows Server 2K8, Windows Server 2K8 R2, Windows 7 x64, Windows Vista.

# Author: David Hall, signalwarrant.com
#
# You can read a list of computers from the computers.txt file and get service information remotely 
# using alternate admin credentials. 

# Admin Credentials
$cred = get-Credential -credential administrator

# Path to your computers.txt file
$computer = gc "c:\scripts\computers.txt"

write-host -foregroundcolor yellow "`nThis gets the service named McAfeeFramework `n"
Get-WMIObject Win32_Service -computer $computer -credential $cred | Where { $_.Name -eq "McAfeeFramework" }

write-host -foregroundcolor yellow "`nThis gets all running Services `n"
Get-WMIObject Win32_Service -computer $computer -credential $cred | Where { $_.state -eq "Running" }

write-host -foregroundcolor yellow "`nThis gets all stopped Services `n"
Get-WMIObject Win32_Service -computer $computer -credential $cred | Where { $_.state -eq "Stopped" }

write-host -foregroundcolor yellow "`nThis gets all Services where startmode is manual `n"
Get-WMIObject Win32_Service -computer $computer -credential $cred | Where { $_.StartMode -eq "Manual" }

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.