Skip to content

Instantly share code, notes, and snippets.

@stephanlinke
Created April 6, 2018 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanlinke/8e3531be56afec617591f91f2933b3d1 to your computer and use it in GitHub Desktop.
Save stephanlinke/8e3531be56afec617591f91f2933b3d1 to your computer and use it in GitHub Desktop.
Read Status of automatic services on a given host
param(
[string]$computerName="",
[string]$IgnoreList = @("Dell Digital Delivery Service","Skype Updater", "Software Protection","Manager für heruntergeladene Karten"),
[string]$UserName = "",
[string]$Password = ''
)
$IgnoreScript = 'Google Update Service (gupdate)'
$IgnoreCombined = $IgnoreList + $IgnoreScript
# Generate Credentials Object
$SecPasswd = ConvertTo-SecureString $Password -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ($UserName, $secpasswd)
$Services = Invoke-Command -Credential $Credentials -ComputerName $computerName -ScriptBlock {
$Services = (Get-Service| Select-Object DisplayName,Status,StartType | Where-Object {$_.StartType -eq "Automatic" -and $_.Status -eq "Stopped" })
return $Services
}
$FilteredServices = @();
Foreach($Service in $Services){
if(-Not ($IgnoreCombined.Contains($Service.DisplayName)))
{ $FilteredServices += $Service }
}
if($FilteredServices.Count -ne 0)
{ Write-Host ([string]::Format("{0}:There are {0} stopped automatic services: {1}",$FilteredServices.Count,($FilteredServices | Select -Expand DisplayName ) -join ", ")) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment