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: Clear Windows Clipboard

Many of us are using Remote Desktop nowadays. As such, clipboard can sometimes be out…

PowerShell Script to Send Email

Use this newer method: https://blog.kimconnect.com/powershell-script-to-send-emails/ ### Variables section ###$fromaddress = "[email protected]"$toaddress = "[email protected]"$bccaddress = ""$CCaddress…

Tasks to Perform After Windows 10 Upgrade

Target for Windows upgrade cleanup: C:\$Windows.~BT\* C:\$Windows.~LS\* C:\$Windows.~WS\* C:\ESD\Download\* C:\ESD\Windows\* C:\$WINDOWS.~Q\* C:\$INPLACE.~TR\* C:\Windows.old\* C:\Windows\Panther Please…