Additional Script Updates

This commit is contained in:
Andrew Amason
2025-05-19 15:19:36 -04:00
parent ec2b22290a
commit 9c8438d7d1
136 changed files with 1595 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
# Check if a specific registry key exists and a service is running
$regPath = "HKLM:\Software\MyCompany\Settings"
$regName = "ComplianceSetting"
$serviceName = "MyService"
$regExists = Test-Path "$regPath\$regName"
$serviceStatus = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
if ($regExists -and $serviceStatus.Status -eq "Running") {
Write-Output "Compliance settings are in place."
} else {
Write-Output "Compliance settings are not in place."
}

View File

@@ -0,0 +1,17 @@
# Ensure the registry key is set and the service is running
$regPath = "HKLM:\Software\MyCompany\Settings"
$regName = "ComplianceSetting"
$regValue = "Enabled"
$serviceName = "MyService"
if (-Not (Test-Path "$regPath\$regName")) {
New-Item -Path $regPath -Force | Out-Null
New-ItemProperty -Path $regPath -Name $regName -Value $regValue -PropertyType String -Force | Out-Null
} else {
Set-ItemProperty -Path $regPath -Name $regName -Value $regValue
}
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
if ($service.Status -ne "Running") {
Start-Service -Name $serviceName
}