mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-05 22:28:31 +00:00
* cleaned up typo, fixes, grammatical and other related fixes (#2) * typo in Lightshot app name * remove trailing comma in applications.json * consistent capitalization of Windows, WinGet - only user-facing text - includes update to devdocs-generator.ps1, so docs for tweaks modifying registry will have `Windows settings` rather than `windows settings` * various fixes for typos, style, punctuation and capitalization * capitalize 'AM' * Update README.md change formatting for GitHub UI interaction form code format (` `) to bold md Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com> * typos and wording in docs --------- Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
43 lines
1.3 KiB
PowerShell
43 lines
1.3 KiB
PowerShell
function Set-WinUtilScheduledTask {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Enables/Disables the provided Scheduled Task
|
|
|
|
.PARAMETER Name
|
|
The path to the Scheduled Task
|
|
|
|
.PARAMETER State
|
|
The State to set the Task to
|
|
|
|
.EXAMPLE
|
|
Set-WinUtilScheduledTask -Name "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" -State "Disabled"
|
|
|
|
#>
|
|
param (
|
|
$Name,
|
|
$State
|
|
)
|
|
|
|
try {
|
|
if($State -eq "Disabled") {
|
|
Write-Host "Disabling Scheduled Task $Name"
|
|
Disable-ScheduledTask -TaskName $Name -ErrorAction Stop
|
|
}
|
|
if($State -eq "Enabled") {
|
|
Write-Host "Enabling Scheduled Task $Name"
|
|
Enable-ScheduledTask -TaskName $Name -ErrorAction Stop
|
|
}
|
|
} catch [System.Exception] {
|
|
if($psitem.Exception.Message -like "*The system cannot find the file specified*") {
|
|
Write-Warning "Scheduled Task $Name was not found."
|
|
} else {
|
|
Write-Warning "Unable to set $Name due to unhandled exception."
|
|
Write-Warning $psitem.Exception.Message
|
|
}
|
|
} catch {
|
|
Write-Warning "Unable to run script for $name due to unhandled exception."
|
|
Write-Warning $psitem.Exception.StackTrace
|
|
}
|
|
}
|