Private/Get-BootTime.ps1

function Get-BootTime {
    <#
    .SYNOPSIS
        Returns the system's last boot time as a [DateTime].
 
    .DESCRIPTION
        Wraps Get-CimInstance -ClassName Win32_OperatingSystem and returns the
        LastBootUpTime property. Using CIM (rather than the deprecated Get-WmiObject)
        ensures compatibility with both PowerShell 5.1 and PowerShell 7+.
 
    .OUTPUTS
        [DateTime] — The system's last boot time.
 
    .NOTES
        Author: Aaron AlAnsari
        Created: 2026-02-25
    #>


    [CmdletBinding()]
    [OutputType([DateTime])]
    param ()

    return (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
}