How do I get report output to the screen and not the console #691
Unanswered
dennisa72295
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to get a report of servers that may or may not need to be rebooted. The list is read from a file, but if there are none that need to be rebooted, I get nothing on the screen. If there are warnings like "RPC server unavailable.", etc. they show on the powershell console. What am I missing here? Here's the code I'm working with:
Import-Module Pode
Import-Module Pode.Web
import-module pendingreboot
--- LOGIC BLOCK 1: THE SCAN ---
$ScanLogic = {
# 1. RESET THE UI IMMEDIATELY
# This acts as a "Keep-Alive" for the browser connection
Update-PodeWebComponent -Id 'ReportOutput' -Content {
New-PodeWebText -Value "Scan in progress... please wait." -Colour Blue
}
}
--- LOGIC BLOCK 2: THE REBOOT ---
$RebootLogic = {
$srv = $WebEvent.Data.ServerName
$time = $WebEvent.Data.RebootTime
try {
$dt = [DateTime]::Parse($time)
Invoke-Command -ComputerName $srv -ScriptBlock {
param($T)
$action = New-ScheduledTaskAction -Execute 'shutdown.exe' -Argument '/r /t 0 /f'
$trigger = New-ScheduledTaskTrigger -At $T -Once
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "PodeReboot" -User "System" -Force
} -ArgumentList $dt -ErrorAction Stop
}
--- SERVER START ---
Start-PodeServer {
Add-PodeEndpoint -Address 127.0.0.1 -Port 8080 -Protocol Http
Use-PodeWebTemplates -Title 'Server Monitor'
}
Beta Was this translation helpful? Give feedback.
All reactions