Skip to content

Commit

Permalink
Introduce new optional argument to randomly delay execution (#403)
Browse files Browse the repository at this point in the history
* Introduce new optional argument to randomly delay execution

* Add missing word in parameter description
  • Loading branch information
cpuschma authored Jan 8, 2024
1 parent f866dc7 commit 0749b05
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mdm-scripts/windows/scan.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
If provided, the cnspec binary will be downloaded to the specified path. Default: C:\ProgramData\Mondoo\mondoo.yml
.PARAMETER LogDir
The script output is logged to a file. Default: C:\Windows\Temp\
.PARAMETER RandomDelay
Random delay in seconds before execution of the script
.EXAMPLE
scan.ps1 -Product cnspec
scan.ps1 -RegistrationToken 'InsertTokenHere'
Expand All @@ -38,7 +40,8 @@ Param(
[string] $ExecutionPath = '',
[string] $DownloadPath = '',
[string] $ConfigFile = "C:\ProgramData\Mondoo\mondoo.yml",
[string] $LogDir = ""
[string] $LogDir = "",
[int] $RandomDelay = ""
)

# Set Log location
Expand Down Expand Up @@ -129,8 +132,15 @@ info "Arguments:"
info (" DownloadPath: {0}" -f $DownloadPath)
info (" ConfigFile: {0}" -f $ConfigFile)
info (" LogDir: {0}" -f $LogDir)
info (" RandomDelay: {0}" -f $RandomDelay)
info ""

if ($RandomDelay -gt 0) {
$delay = Get-Random -Minimum 0 -Maximum $RandomDelay
info ("Delaying execution by {0} seconds" -f $delay)
Start-Sleep -Seconds $delay
}

# Set proxy environment variables
If (![string]::IsNullOrEmpty($Proxy)) {
[Environment]::SetEnvironmentVariable("HTTP_PROXY", $Proxy)
Expand Down

0 comments on commit 0749b05

Please sign in to comment.