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: Create Daily VSS Snapshot of Volumes on Local Windows Machine

<# Daily-VSS-Snapshot-Windows-Standalone-FileServer.ps1 Functions: 1. Dynamically detect all volumes on local machine 2. Take snapshots of…

PowerShell: Assign Guest Virtual Machine to a Cloud in VMM

# assignVmsToCloud.ps1 # version 0.02 # The following function assigns a guest VM into a…

Harden Windows Server 2016

# IE Enhanced Security:$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"    Set-ItemProperty -Path…