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: Automating Dynamics CRM Migration

This is the source code that has been used to move hundreds of Dynamics CRM…

How to Use Google SMTP Relay with Sendmail

Check to see if TLS is enabled:# sendmail -d0.1 -bv rootMake a certs directory:# mkdir…

PowerShell: Connect to Office 365 Exchange Online

function disconnectExchangeOnline{ <# manually check sessions PS C:\Windows\system32> Get-PSSession Id Name ComputerName ComputerType State ConfigurationName…