winutil/functions/private/Set-WinUtilService.ps1
Chris Titus cfb04b5fc3
Test 2023 08 02 (#950)
* Fix Restore Points before tweaks

* Compile Winutil

* Update Set-WinUtilRestorePoint.ps1

* Compile Winutil

* add snappy driver installer origin (#936)

* fix when User name have space (#937)

* Compile Winutil

* Add Applications (Fixed) (#944)

* Add Applications (Fixed)

This fixes #940 by removing OperaGX, fixing alphabetization, and removing my instance of Neovim which I didn't notice was added recently.

* Update winutil.ps1

* Update inputXML.xaml

---------

Co-authored-by: Chris Titus <contact@christitus.com>

* Compile Winutil

* removing service stops in services tweak

* Fix pin not working for microsoft accounts

* Compile Winutil

* Remove verbose code

* Compile Winutil

---------

Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: Padsala Tushal <57517785+padsalatushal@users.noreply.github.com>
Co-authored-by: AdamJedl <100023363+AdamJedl@users.noreply.github.com>
Co-authored-by: AshlynOrSomethin <31773733+AshlynOrSomethin@users.noreply.github.com>
2023-08-08 16:44:10 -05:00

34 lines
895 B
PowerShell

Function Set-WinUtilService {
<#
.DESCRIPTION
This function will change the startup type of services and start/stop them as needed
.EXAMPLE
Set-WinUtilService -Name "HomeGroupListener" -StartupType "Manual"
#>
param (
$Name,
$StartupType
)
try {
Write-Host "Setting Service $Name to $StartupType"
# Check if the service exists
$service = Get-Service -Name $Name -ErrorAction Stop
# Service exists, proceed with changing properties
$service | Set-Service -StartupType $StartupType -ErrorAction Stop
}
catch [System.ServiceProcess.ServiceNotFoundException] {
Write-Warning "Service $Name was not found"
}
catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $_.Exception.Message
}
}