source/public/Set-MS365HealthReportLastRunTime.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Function Set-MS365HealthReportLastRunTime {
    [CmdletBinding()]
    param (
        [parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$TenantID,

        [parameter()]
        [datetime]$LastRunTime
    )
    $now = Get-Date
    $RegPath = "HKCU:\Software\MS365HealthReport\$TenantID"

    $regSplat = @{
        Path  = $RegPath
        Value = $(
            if ($LastRunTime) {
                "{0:yyyy-MM-dd H:mm}" -f $LastRunTime
            }
            else {
                $now
            }
        )
    }
    $null = New-Item @regSplat -Force
}