Get PodeServerUptime - mdaneri/Pode GitHub Wiki
Retrieves the server uptime in milliseconds or a human-readable format.
Get-PodeServerUptime [-Total] [[-Format] <String>] [-ExcludeMilliseconds] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
The `Get-PodeServerUptime` function calculates the server's uptime since its last start or total uptime since initial load, depending on the `-Total` switch. By default, the uptime is returned in milliseconds. When the `-Format` parameter is used, the uptime can be returned in various human-readable styles:
- `Milliseconds` (default): Raw uptime in milliseconds.
- `Concise`: A short format like "1d 2h 3m".
- `Compact`: A condensed format like "01:10:17:36".
- `Verbose`: A detailed format like "1 day, 2 hours, 3 minutes, 5 seconds, 200 milliseconds". The `-ExcludeMilliseconds` switch allows removal of milliseconds from human-readable output.
$currentUptime = Get-PodeServerUptime
# Output: 123456789 (milliseconds)
$totalUptime = Get-PodeServerUptime -Total
# Output: 987654321 (milliseconds)
$readableUptime = Get-PodeServerUptime -Format Concise
# Output: "1d 10h 17m"
$verboseUptime = Get-PodeServerUptime -Format Verbose
# Output: "1 day, 10 hours, 17 minutes, 36 seconds, 789 milliseconds"
$compactUptime = Get-PodeServerUptime -Format Compact
# Output: "01:10:17:36"
$compactUptimeNoMs = Get-PodeServerUptime -Format Compact -ExcludeMilliseconds
# Output: "01:10:17:36"
Omits milliseconds from the human-readable output when `-Format` is not `Milliseconds`.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the desired output format for the uptime. Allowed values:
- `Milliseconds` (default): Uptime in raw milliseconds.
- `Concise`: Human-readable in a short form (e.g., "1d 2h 3m").
- `Compact`: Condensed form (e.g., "01:10:17:36").
- `Verbose`: Detailed format (e.g., "1 day, 2 hours, 3 minutes, 5 seconds").
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: Milliseconds
Accept pipeline input: False
Accept wildcard characters: False{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseRetrieves the total server uptime since the initial load, regardless of any restarts.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This function is part of Pode's utility metrics to monitor server uptime.