Created
April 6, 2018 12:35
-
-
Save stephanlinke/8e3531be56afec617591f91f2933b3d1 to your computer and use it in GitHub Desktop.
Read Status of automatic services on a given host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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