Guest User

Untitled

a guest
Apr 14th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. param(
  2. [string]$computerName="",
  3. [string]$IgnoreList = @("Dell Digital Delivery Service","Skype Updater", "Software Protection","Manager für heruntergeladene Karten"),
  4. [string]$UserName = "",
  5. [string]$Password = ''
  6. )
  7.  
  8. $IgnoreScript = 'Google Update Service (gupdate)'
  9. $IgnoreCombined = $IgnoreList + $IgnoreScript
  10.  
  11. # Generate Credentials Object
  12. $SecPasswd = ConvertTo-SecureString $Password -AsPlainText -Force
  13. $Credentials = New-Object System.Management.Automation.PSCredential ($UserName, $secpasswd)
  14.  
  15.  
  16. $Services = Invoke-Command -Credential $Credentials -ComputerName $computerName -ScriptBlock {
  17. $Services = (Get-Service| Select-Object DisplayName,Status,StartType | Where-Object {$_.StartType -eq "Automatic" -and $_.Status -eq "Stopped" })
  18. return $Services
  19. }
  20.  
  21. $FilteredServices = @();
  22.  
  23. Foreach($Service in $Services){
  24. if(-Not ($IgnoreCombined.Contains($Service.DisplayName)))
  25. { $FilteredServices += $Service }
  26. }
  27.  
  28. if($FilteredServices.Count -ne 0)
  29. { Write-Host ([string]::Format("{0}:There are {0} stopped automatic services: {1}",$FilteredServices.Count,($FilteredServices | Select -Expand DisplayName ) -join ", ")) }
Add Comment
Please, Sign In to add comment