Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Interactive scripts support #2086

Open
P6g9YHK6 opened this issue Nov 28, 2024 · 1 comment
Open

[Feature Request] Interactive scripts support #2086

P6g9YHK6 opened this issue Nov 28, 2024 · 1 comment

Comments

@P6g9YHK6
Copy link

Is your feature request related to a problem? Please describe.
Any scripts that "manage" (list/add/remove) something does not fit in TRMM at the moment and require some mental gymnastics to make it work
When running scripts, it is complicated to have scripts with multiple options and or choices to help setting variables for the run

And set "profiles" inside scripts with multiple choices already pre-made

Describe the solution you'd like
When running a script if the script is set as "interactive" open a terminal to interact with the remote script currently running.
once the script is over or timeout add the whole terminal interaction to the history
this would also allow people to also integrate compiled binaries to scripts that require user interaction by calling them (i was thinking about win-acme for exemple or any other cli tool)

these would obviously not be allowed to be used in policy/tasks/checks as they by nature require user inputs

Describe alternatives you've considered
lots of work and annoying things

Additional context
image

Here an extreme exemple of what could be run in this feature:

Write-Host "The shadows beckon... Welcome to the PowerShell Demo, where nothing is as it seems..." -ForegroundColor DarkGray
$name = Read-Host "Enter your name, if you dare..."
$age = Read-Host "How many years have you walked this cursed earth?"
$color = Read-Host "What is the color of your soul?"
Write-Host "Ah, $name... You are $age years old, and your soul is stained with the color of $color." -ForegroundColor DarkRed

$password = Read-Host "Give me your password, the key to your inner sanctum..." -AsSecureString
$plainPassword = [System.Net.NetworkCredential]::new("", $password).Password
Write-Host "The password... has been revealed: $plainPassword" -ForegroundColor DarkYellow

do { 
    $number = Read-Host "A number, between 1 and 10. Choose wisely, for the consequences are real."
    if ($number -lt 1 -or $number -gt 10) { Write-Host "That was a foolish choice. Try again." -ForegroundColor Red }
} while ($number -lt 1 -or $number -gt 10)
Write-Host "You dared to choose $number... A valid choice, but are you ready for what's next?" -ForegroundColor DarkRed

$file = "C:\path\to\file.txt"
$confirmation = Read-Host "Are you sure you wish to delete the cursed file $file? (yes/no)"
if ($confirmation -eq "yes") { Write-Host "The file is no more. It has been erased from existence." -ForegroundColor Black }
elseif ($confirmation -eq "no") { Write-Host "You hesitate. The file remains, a silent witness to your fear." -ForegroundColor DarkGray }
else { Write-Host "The abyss swallows your indecision. The file remains, untouched." -ForegroundColor DarkGray }

Write-Host "You cannot escape. The task must be completed..." -ForegroundColor DarkGray
$steps = 10
for ($i = 1; $i -le $steps; $i++) {
    $percent = ($i / $steps) * 100
    Write-Progress -PercentComplete $percent -Status "The process continues..." -Activity "Step $i of $steps"
    Start-Sleep -Seconds 1
}
Write-Host "It is done. The task is complete. But at what cost?" -ForegroundColor DarkRed

Write-Host "Choose your path carefully..." -ForegroundColor DarkMagenta
Write-Host "1. Reveal the forbidden knowledge of the system."
Write-Host "2. Gaze into the abyss of the current date and time."
Write-Host "3. Escape... or try to."
$choice = Read-Host "Enter your choice (1, 2, or 3)"
switch ($choice) {
    1 { Write-Host "The system groans in pain, revealing its secrets..." -ForegroundColor Black; Get-ComputerInfo }
    2 { Write-Host "The current date and time: $(Get-Date). Time is but a fleeting illusion." -ForegroundColor DarkCyan }
    3 { Write-Host "You seek to escape, but can you ever truly escape your fate?" -ForegroundColor DarkRed; exit }
    default { Write-Host "Your choices are meaningless in the face of the void." -ForegroundColor DarkRed }
}

$timeout = 5
Write-Host "You have $timeout seconds to prove your resolve and enter your name:"
$startTime = Get-Date
do {
    $elapsedTime = (Get-Date) - $startTime
    if ($elapsedTime.TotalSeconds -gt $timeout) { Write-Host "Time is up. The moment has passed." -ForegroundColor DarkRed; exit }
    $name = Read-Host "Enter your name, before the darkness claims it."
} while (-not $name)
Write-Host "Ah, $name... You have managed to survive, for now." -ForegroundColor DarkRed

Write-Host "Choose an option, if you dare..." -ForegroundColor DarkGray
Write-Host "1. Hear a joke... if you can still laugh."
Write-Host "2. Gaze upon the endless void of time."
Write-Host "3. Exit the demo... or do you even want to?"
$choice = Read-Host "Enter the number of your choice (1, 2, or 3)"
switch ($choice) {
    1 { Write-Host "Why don't skeletons fight each other? They lack the courage... and the flesh." -ForegroundColor DarkGray }
    2 { Write-Host "Today’s date is: $(Get-Date). A fleeting moment in an infinite abyss." -ForegroundColor DarkCyan }
    3 { Write-Host "The demo ends. But the darkness remains. Always." -ForegroundColor Black; exit }
    default { Write-Host "You failed to choose. The darkness closes in." -ForegroundColor DarkRed; exit }
}

$answer = Read-Host "Do you wish to continue in this twisted game? (yes/no)"
if ($answer -eq "yes") { Write-Host "The game continues. The abyss watches." -ForegroundColor DarkGray }
elseif ($answer -eq "no") { Write-Host "You retreat into the shadows... for now." -ForegroundColor DarkRed }
else { Write-Host "Indecision is the greatest punishment. The demo ends now." -ForegroundColor Black }

Write-Host "The demo has come to an end... or has it?" -ForegroundColor DarkRed

@P6g9YHK6
Copy link
Author

P6g9YHK6 commented Dec 1, 2024

it would fix this one too #657
let the people adapt their script to fix the premade option rather than having to redo the whole rmm scripting stuff everytime someone needs something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant