Fix indent

This commit is contained in:
Jeffrey
2026-08-23 22:48:06 +02:00
parent 20d206cb9b
commit 8755d66452
+37 -37
View File
@@ -53,30 +53,30 @@ function Disable-TelemetryScheduledTasks {
try { try {
$result = Invoke-NonBlocking -ScriptBlock { $result = Invoke-NonBlocking -ScriptBlock {
param($path, $name) param($path, $name)
try {
Import-Module ScheduledTasks -ErrorAction Stop
$taskObj = Get-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop
}
catch {
if ($_.Exception -isnot [System.Management.Automation.CommandNotFoundException] -and $_.CategoryInfo.Category -eq [System.Management.Automation.ErrorCategory]::ObjectNotFound) {
return @{ Success = $true; Status = 'NotFound' }
}
return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message }
}
if (-not $taskObj) {
return @{ Success = $true; Status = 'NotFound' }
}
if ($taskObj.State -ne 'Disabled') {
try { try {
Disable-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop | Out-Null Import-Module ScheduledTasks -ErrorAction Stop
return @{ Success = $true; Status = 'Disabled' } $taskObj = Get-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop
} }
catch { catch {
if ($_.Exception -isnot [System.Management.Automation.CommandNotFoundException] -and $_.CategoryInfo.Category -eq [System.Management.Automation.ErrorCategory]::ObjectNotFound) {
return @{ Success = $true; Status = 'NotFound' }
}
return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message } return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message }
} }
} if (-not $taskObj) {
return @{ Success = $true; Status = 'AlreadyDisabled' } return @{ Success = $true; Status = 'NotFound' }
}
if ($taskObj.State -ne 'Disabled') {
try {
Disable-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop | Out-Null
return @{ Success = $true; Status = 'Disabled' }
}
catch {
return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message }
}
}
return @{ Success = $true; Status = 'AlreadyDisabled' }
} -ArgumentList @($task.Path, $task.Name) } -ArgumentList @($task.Path, $task.Name)
} }
catch { catch {
@@ -127,29 +127,29 @@ function Enable-TelemetryScheduledTasks {
try { try {
$result = Invoke-NonBlocking -ScriptBlock { $result = Invoke-NonBlocking -ScriptBlock {
param($path, $name) param($path, $name)
try {
Import-Module ScheduledTasks -ErrorAction Stop
$taskObj = Get-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop
}
catch {
if ($_.Exception -isnot [System.Management.Automation.CommandNotFoundException] -and $_.CategoryInfo.Category -eq [System.Management.Automation.ErrorCategory]::ObjectNotFound) {
return @{ Success = $true; Status = 'NotFound' }
}
return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message }
}
if (-not $taskObj) {
return @{ Success = $true; Status = 'NotFound' }
}
if ($taskObj.State -eq 'Disabled') {
try { try {
Enable-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop | Out-Null Import-Module ScheduledTasks -ErrorAction Stop
return @{ Success = $true; Status = 'Enabled' } $taskObj = Get-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop
} }
catch { catch {
if ($_.Exception -isnot [System.Management.Automation.CommandNotFoundException] -and $_.CategoryInfo.Category -eq [System.Management.Automation.ErrorCategory]::ObjectNotFound) {
return @{ Success = $true; Status = 'NotFound' }
}
return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message } return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message }
} }
} if (-not $taskObj) {
return @{ Success = $true; Status = 'NotFound' }
}
if ($taskObj.State -eq 'Disabled') {
try {
Enable-ScheduledTask -TaskPath $path -TaskName $name -ErrorAction Stop | Out-Null
return @{ Success = $true; Status = 'Enabled' }
}
catch {
return @{ Success = $false; Status = 'Error'; Error = $_.Exception.Message }
}
}
return @{ Success = $true; Status = 'AlreadyEnabled' } return @{ Success = $true; Status = 'AlreadyEnabled' }
} -ArgumentList @($task.Path, $task.Name) } -ArgumentList @($task.Path, $task.Name)
} }