-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfigureServices.ps1
67 lines (39 loc) · 1.26 KB
/
ConfigureServices.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (c) 2019 Gurjit Singh
# This source code is licensed under the MIT license that can be found in
# the accompanying LICENSE file or at https://opensource.org/licenses/MIT.
# Imports
try {
# Catch All Errors
$ErrorActionPreference = "Stop"
Import-Module -Force $PSScriptRoot\Import\Get-AnyKeyTo.psm1
Import-Module -Force $PSScriptRoot\Import\Get-Admin.psm1
Import-Module -Force $PSScriptRoot\Import\Set-ScriptStartEnd.psm1
# Configuration
$Services2Disable = Import-PowerShellDataFile $PSScriptRoot\Config\Disable-ServicesConf.psd1
}
catch {
Write-Output ("n`nError Details: `n$($PSItem.Exception)`n" +
"`n$($PSItem.CategoryInfo)`n")
Exit
}
finally {
# Clear Flags
$ErrorActionPreference = "Continue"
}
# Global Vars
$Title = "Configure Services"
$LogFile = "Log.txt"
# Elevate privileges
Get-Admin
# Tucked away Boilerplate code
Set-ScriptStart -Title $Title -LogFile $LogFile
### Start Here
$ErrorActionPreference = "SilentlyContinue"
foreach ($Service in $Services2Disable.keys) {
Write-Output ("$Service" + " is set to " + "$($Services2Disable.$Service)")
Set-Service -Name $Service -StartupType $Services2Disable.$Service
}
### End Here
# Tucked away Boilerplate code
Set-ScriptEnd