functions/Save-PSClock.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
27
Function Save-PSClock {
    [CmdletBinding(SupportsShouldProcess)]
    Param()

    Write-Verbose "Starting $($myinvocation.MyCommand)"
    if ($IsLinux -OR $isMacOS) {
        Write-Warning "This command requires a Windows platform"
        return
    }

    #define a list of properties to export
    $props = @{Name="DateFormat";Expression={$_.Format}},"Color",
    @{Name="FontSize";Expression={$_.Size}},
    @{Name="FontWeight";Expression={$_.weight}},"FontFamily",
    @{Name="FontStyle";Expression={$_.Style}},"OnTop",
    @{Name="Position";Expression = {$_.CurrentPosition}}

    if ($global:PSClockSettings) {
        Write-Verbose "Saving PSClock settings to $SavePath"
        Get-PSClock | Select-Object -property $props | Export-Clixml -Path $SavePath
    }
    else {
        Write-Warning "Can't find a PSClock. Do you need to start one?"
    }

    Write-Verbose "Ending $($myinvocation.MyCommand)"
}