add pode and api scripts

This commit is contained in:
Alex Kup 2023-10-14 12:06:13 +03:00 committed by GitHub
parent 30a3d7711e
commit 94bc297ea1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 783 additions and 3 deletions

29
Scripts/Get-Uptime.psm1 Normal file
View file

@ -0,0 +1,29 @@
function Get-Uptime {
<#
.SYNOPSIS
Remote and local check uptime via WMI
.DESCRIPTION
Example:
Get-Uptime localhost # default (or remote host)
.LINK
https://github.com/Lifailon
#>
Param (
$srv="localhost"
)
if ($srv -like "localhost") {
$boottime = Get-CimInstance Win32_OperatingSystem | select LastBootUpTime
} else {
$boottime = Get-CimInstance -ComputerName $srv Win32_OperatingSystem | select LastBootUpTime
}
$datetime = (Get-Date) - $boottime.LastBootUpTime
$global:uptime = [string]$datetime.Days+" days "+[string]$datetime.Hours+" hours "+
[string]$datetime.Minutes+" minutes"
$LastTime = [string]$boottime.LastBootUpTime.DateTime
$Collections = New-Object System.Collections.Generic.List[System.Object]
$Collections.Add([PSCustomObject]@{
Uptime = $uptime;
BootTime = $LastTime
})
$Collections
}