Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/controllers/webserver/handlers/computers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ func (h *Handler) CreateWindowsTaskConfig(t *openuem_ent.Task) (*wingetcfg.WinGe
}
cfg.AddResource(msiUninstall)
case task.TypePowershellScript:
msiUninstall, err := wingetcfg.ExecutePowershellScript(taskID, t.Name, t.Script, t.ScriptRun.String())
msiUninstall, err := wingetcfg.ExecutePowershellScript(taskID, t.Name, t.Script, t.ScriptRun.String(), t.ScriptExecutable)
if err != nil {
return nil, err
}
Expand Down
6 changes: 6 additions & 0 deletions internal/controllers/webserver/handlers/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@ func validatePowerShellScript(c echo.Context) (*models.TaskConfig, error) {
return nil, errors.New(i18n.T(c.Request().Context(), "tasks.shell_wrong_run_config"))
}

taskConfig.ShellExecute = c.FormValue("powershell-executable")
validEngines := []string{"", "powershell", "pwsh", "auto"}
if taskType == "powershell_type" && !slices.Contains(validEngines, taskConfig.ShellExecute) {
return nil, errors.New(i18n.T(c.Request().Context(), "tasks.shell_wrong_run_config"))
}

return &taskConfig, nil
}

Expand Down
4 changes: 2 additions & 2 deletions internal/models/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (m *Model) AddTaskToProfile(c echo.Context, profileID int, cfg TaskConfig)
return query.Exec(context.Background())
case task.TypePowershellScript.String():
return query.
SetScript(cfg.ShellScript).SetScriptRun(task.ScriptRun(cfg.ShellRunConfig)).Exec(context.Background())
SetScript(cfg.ShellScript).SetScriptRun(task.ScriptRun(cfg.ShellRunConfig)).SetScriptExecutable(cfg.ShellExecute).Exec(context.Background())
case task.TypeUnixScript.String():
return query.
SetScript(cfg.ShellScript).SetScriptCreates(cfg.ShellCreates).SetScriptExecutable(cfg.ShellExecute).Exec(context.Background())
Expand Down Expand Up @@ -391,7 +391,7 @@ func (m *Model) UpdateProfileTask(c echo.Context, taskID int, cfg TaskConfig) er
}
return query.Exec(context.Background())
case task.TypePowershellScript.String():
return query.SetScript(cfg.ShellScript).SetScriptRun(task.ScriptRun(cfg.ShellRunConfig)).Exec(context.Background())
return query.SetScript(cfg.ShellScript).SetScriptRun(task.ScriptRun(cfg.ShellRunConfig)).SetScriptExecutable(cfg.ShellExecute).Exec(context.Background())
case task.TypeUnixScript.String():
return query.SetScript(cfg.ShellScript).SetScriptCreates(cfg.ShellCreates).SetScriptExecutable(cfg.ShellExecute).Exec(context.Background())
case task.TypeFlatpakInstall.String(), task.TypeFlatpakUninstall.String():
Expand Down
4 changes: 4 additions & 0 deletions internal/views/locales/ca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ ca:
shell_run_once: "Executeu només una vegada si té èxit"
shell_run_always: "Executeu cada vegada que s'aplica el perfil"
shell_wrong_run_config: "La configuració d'execució no és vàlida"
powershell_executable: "Motor de PowerShell"
powershell_engine_51: "Windows PowerShell 5.1"
powershell_engine_7: "PowerShell 7+ (pwsh)"
powershell_engine_auto: "Auto (utilitza PowerShell 7+ si està disponible, si no 5.1)"
task_agent: "OS de l'agent"
task_agent_description: "Especifiqueu l'agent del sistema operatiu..."
wrong_agenttype: "El tipus d'agent no és vàlid"
Expand Down
4 changes: 4 additions & 0 deletions internal/views/locales/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ de:
shell_run_once: "Nur einmal ausführen, wenn erfolgreich"
shell_run_always: "Bei jeder Anwendung des Profils ausführen"
shell_wrong_run_config: "Ungültige Ausführungskonfiguration"
powershell_executable: "PowerShell-Engine"
powershell_engine_51: "Windows PowerShell 5.1"
powershell_engine_7: "PowerShell 7+ (pwsh)"
powershell_engine_auto: "Auto (PowerShell 7+ verwenden, falls verfügbar, sonst 5.1)"
task_agent: "Betriebssystem des Agents"
task_agent_description: "Geben Sie das Betriebssystem des Agents an..."
wrong_agenttype: "Ungültiger Agent-Typ"
Expand Down
4 changes: 4 additions & 0 deletions internal/views/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ en:
shell_run_once: "Run only once if successful"
shell_run_always: "Run every time the profile is applied"
shell_wrong_run_config: "Run configuration is not valid"
powershell_executable: "PowerShell engine"
powershell_engine_51: "Windows PowerShell 5.1"
powershell_engine_7: "PowerShell 7+ (pwsh)"
powershell_engine_auto: "Auto (use PowerShell 7+ if available, otherwise 5.1)"
task_agent: "Agent's OS"
task_agent_description: "Specify the OS agent..."
wrong_agenttype: "Agent's type is not valid"
Expand Down
4 changes: 4 additions & 0 deletions internal/views/locales/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ es:
shell_run_once: "Ejecutar solo una vez si tiene éxito"
shell_run_always: "Ejecutar cada vez que se aplique el perfil"
shell_wrong_run_config: "La configuración de ejecución no es válida"
powershell_executable: "Motor de PowerShell"
powershell_engine_51: "Windows PowerShell 5.1"
powershell_engine_7: "PowerShell 7+ (pwsh)"
powershell_engine_auto: "Auto (usar PowerShell 7+ si está disponible, si no 5.1)"
task_agent: "S.O del agente"
task_agent_description: "Especifique el S.O del agente..."
wrong_agenttype: "El tipo de agente no es válido"
Expand Down
4 changes: 4 additions & 0 deletions internal/views/locales/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ fr:
shell_run_once: "Exécuter une seule fois si réussi"
shell_run_always: "Exécuter chaque fois que le profil est appliqué"
shell_wrong_run_config: "La configuration d'exécution n'est pas valide"
powershell_executable: "Moteur PowerShell"
powershell_engine_51: "Windows PowerShell 5.1"
powershell_engine_7: "PowerShell 7+ (pwsh)"
powershell_engine_auto: "Auto (utiliser PowerShell 7+ si disponible, sinon 5.1)"
task_agent: "Système d'exploitation de l'agent"
task_agent_description: "Spécifier l'agent du système d'exploitation..."
wrong_agenttype: "Le type d'agent n'est pas valide"
Expand Down
4 changes: 4 additions & 0 deletions internal/views/locales/no.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ no:
shell_run_once: "Kjør bare én gang hvis vellykket"
shell_run_always: "Kjør hver gang profilen brukes"
shell_wrong_run_config: "Kjøringskonfigurasjon er ikke gyldig"
powershell_executable: "PowerShell-motor"
powershell_engine_51: "Windows PowerShell 5.1"
powershell_engine_7: "PowerShell 7+ (pwsh)"
powershell_engine_auto: "Auto (bruk PowerShell 7+ hvis tilgjengelig, ellers 5.1)"
task_agent: "Agentens OS"
task_agent_description: "Spesifiser OS-agenten..."
wrong_agenttype: "Agenttype er ikke gyldig"
Expand Down
4 changes: 4 additions & 0 deletions internal/views/locales/pt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ pt:
shell_run_once: "Executar apenas uma vez se bem-sucedido"
shell_run_always: "Executar toda vez que o perfil for aplicado"
shell_wrong_run_config: "Configuração de execução não é válida"
powershell_executable: "Motor do PowerShell"
powershell_engine_51: "Windows PowerShell 5.1"
powershell_engine_7: "PowerShell 7+ (pwsh)"
powershell_engine_auto: "Auto (usar PowerShell 7+ se disponível, senão 5.1)"
task_agent: "SO do Agente"
task_agent_description: "Especifique o agente do SO..."
wrong_agenttype: "Tipo de agente não é válido"
Expand Down
14 changes: 14 additions & 0 deletions internal/views/partials/powershell.partials.templ
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,19 @@ templ PowerShellComponent(t *ent.Task) {
<option value={ "always" } selected?={ t != nil && t.ScriptRun.String() == "always" }>{ i18n.T(ctx, "tasks.shell_run_always") }</option>
</select>
</div>
<div id="powershell-executable-section">
<label class="uk-form-label" for="powershell-executable">
{ i18n.T(ctx, "tasks.powershell_executable") }
</label>
<select
class="uk-select"
id="powershell-executable"
name="powershell-executable"
>
<option value="powershell" selected?={ t == nil || t.ScriptExecutable == "" || t.ScriptExecutable == "powershell" }>{ i18n.T(ctx, "tasks.powershell_engine_51") }</option>
<option value="pwsh" selected?={ t != nil && t.ScriptExecutable == "pwsh" }>{ i18n.T(ctx, "tasks.powershell_engine_7") }</option>
<option value="auto" selected?={ t != nil && t.ScriptExecutable == "auto" }>{ i18n.T(ctx, "tasks.powershell_engine_auto") }</option>
</select>
</div>
</div>
}