Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snippets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Lindemark
snippets
Commits
0be5c65e
Commit
0be5c65e
authored
3 months ago
by
Andreas Lindemark
Browse files
Options
Downloads
Patches
Plain Diff
Modified Delay and RandomDelay for triggers @StartOnStartup and $RandomTimes.
Also remove Powershell check.
parent
2eae83d7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Windows/Chocolatey/ScheduleChocolateyUpgrade.ps1
+7
-14
7 additions, 14 deletions
Windows/Chocolatey/ScheduleChocolateyUpgrade.ps1
with
7 additions
and
14 deletions
Windows/Chocolatey/ScheduleChocolateyUpgrade.ps1
+
7
−
14
View file @
0be5c65e
...
@@ -52,7 +52,11 @@ function New-CustomScheduledTask {
...
@@ -52,7 +52,11 @@ function New-CustomScheduledTask {
# Create the triggers
# Create the triggers
$triggers
=
@()
$triggers
=
@()
if
(
$StartOnStartup
)
{
if
(
$StartOnStartup
)
{
$triggers
+=
New-ScheduledTaskTrigger
-AtStartup
if
(
$StartupDelay
)
{
$triggers
+=
New-ScheduledTaskTrigger
-AtStartup
-Delay
"00:05:00"
}
else
{
$triggers
+=
New-ScheduledTaskTrigger
-AtStartup
}
}
}
if
(
$DailyTimes
.
Count
-gt
0
)
{
if
(
$DailyTimes
.
Count
-gt
0
)
{
...
@@ -99,7 +103,7 @@ if (Test-Command -CommandName "choco") {
...
@@ -99,7 +103,7 @@ if (Test-Command -CommandName "choco") {
Write-Host
"Chocolatey is already installed."
Write-Host
"Chocolatey is already installed."
}
else
{
}
else
{
# Install Chocolatey
# Install Chocolatey
Write-Host
"Chocolatey is not installed, please install."
Write-Host
"Chocolatey is not installed, please install.
Exiting...
"
Exit-PSSession
Exit-PSSession
}
}
...
@@ -149,22 +153,11 @@ if ($pwshPath) {
...
@@ -149,22 +153,11 @@ if ($pwshPath) {
$randomTimes
=
if
(
$null
-ne
$taskSettings
.
RandomTimes
)
{
$taskSettings
.
RandomTimes
}
else
{
@()
}
$randomTimes
=
if
(
$null
-ne
$taskSettings
.
RandomTimes
)
{
$taskSettings
.
RandomTimes
}
else
{
@()
}
$randomDays
=
if
(
$null
-ne
$taskSettings
.
RandomDays
)
{
$taskSettings
.
RandomDays
}
else
{
@()
}
$randomDays
=
if
(
$null
-ne
$taskSettings
.
RandomDays
)
{
$taskSettings
.
RandomDays
}
else
{
@()
}
# Add -EnableRandomDelay parameter for the startup trigger if needed
$startupArgument
=
"
$argument
"
if
(
$StartupDelay
)
{
$startupArgument
+=
" -EnableRandomDelay
$true
"
}
if
(
-not
$pwshPath
)
{
Write-Error
"The path to PowerShell executable is not set."
return
}
# Creating a scheduled task to update Chocolatey apps
# Creating a scheduled task to update Chocolatey apps
New-CustomScheduledTask
-TaskName
"AutoUpdateChocolateyApps"
`
New-CustomScheduledTask
-TaskName
"AutoUpdateChocolateyApps"
`
-TaskDescription
"Automatically updates all Chocolatey applications on Startup"
`
-TaskDescription
"Automatically updates all Chocolatey applications on Startup"
`
-Execute
$pwshPath
`
-Execute
$pwshPath
`
-Argument
$
startupA
rgument
`
-Argument
$
a
rgument
`
-StartOnStartup
$startOnStartup
`
-StartOnStartup
$startOnStartup
`
-StartupDelay
$startupDelay
`
-StartupDelay
$startupDelay
`
-DailyTimes
$dailyTimes
`
-DailyTimes
$dailyTimes
`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment