Posted On March 29, 2019

List Autorun Services

kimconnect 0 comments
blog.KimConnect.com >> Codes , Windows >> List Autorun Services
# $cred = get-Credential -credential kdoan-a
$Username = 'kimconnect\kim-Admin
$Password = 'PASSWORD'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$pass 

# Initialize
$servers="servero1","server02"
$services=""
$output=""

# List all currently running services on remote hosts > output to comma delimited strings
function listServices{
Foreach ($server in $servers){
    $runningServices=Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock {Get-WmiObject win32_service -Filter "State='running' AND StartMode='Auto'"};
    $runningServices='"{0}"' -f ($runningServices.name -join '","')
    $output+=@(($server),($runningServices))
    }
    $output    
}
listServices 

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Find Duplicate RDP Sessions on All Remote Desktop Servers Discovered Within the Domain

There's this module called 'PSTerminalServices' that has a method to collect active sessions on all…

PowerShell: Set ACL

# setAcl-v0.01.ps1# # What this script does:# 1. Set permissions on a set of "destination…

SAN Dell Equallogic PS6100E

Per documentation: Port density requirements to support fully redundant configurations and maximum SAN throughput for…