`refactor`: small optimizations in services related functions

- Change message when reverting
main
Plínio Larrubia 2 years ago committed by Plínio Larrubia
parent 490137ca67
commit 8bb5dde163
No known key found for this signature in database
GPG Key ID: 057B0A87CB137C69

@ -1,10 +1,5 @@
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
function Initialize-ServicesModule() {
$Script:EnabledSecurityFilter = @("RemoteAccess", "RemoteRegistry")
$Script:TweakType = "Service"
}
function Find-Service() {
[CmdletBinding()]
[OutputType([Bool])]
@ -17,7 +12,7 @@ function Find-Service() {
return $true
}
Else {
Write-Status -Symbol "?" -Type $TweakType -Status "The $Service was not found." -Warning
Write-Status -Symbol "?" -Type $TweakType -Status "The $Service service was not found ..." -Warning
return $false
}
}
@ -39,7 +34,8 @@ function Set-ServiceStartup() {
[ScriptBlock] $CustomMessage
)
Initialize-ServicesModule
$Script:EnabledSecurityFilter = @("RemoteAccess", "RemoteRegistry")
$Script:TweakType = "Service"
ForEach ($Service in $Services) {
If (Find-Service $Service) {

@ -92,10 +92,10 @@ function Optimize-ServicesRunning() {
If ($Revert) {
Write-Status -Symbol "<" -Type "Service" -Status "Reverting: $Revert" -Warning
Set-ServiceStartup -Manual -Services $ServicesToDisabled -Filter $EnableServicesOnSSD
$CustomMessage = { "Resetting $Service ($((Get-Service $Service).DisplayName)) as 'Manual' on Startup ..." }
Set-ServiceStartup -Manual -Services $ServicesToDisabled -Filter $EnableServicesOnSSD -CustomMessage $CustomMessage
}
If (!$Revert) {
Else {
Set-ServiceStartup -Disabled -Services $ServicesToDisabled -Filter $EnableServicesOnSSD
}
@ -111,7 +111,7 @@ function Main() {
# List all services:
#Get-Service | Select-Object StartType, Status, Name, DisplayName, ServiceType | Sort-Object StartType, Status, Name | Out-GridView
If (!($Revert)) {
If (!$Revert) {
Optimize-ServicesRunning # Enable essential Services and Disable bloating Services
}
Else {

Loading…
Cancel
Save