Grabbing Data using powershell and outputting via variable

I have created a new endpoint which should grab all the system logs from the machine and then I would like to output a count.

Here is my endpoint

$WindowsLogsEndpoint = New-UDEndpoint -Schedule $Schedule -Endpoint {

$GetSystemLogs = Get-EventLog -LogName System

$Cache:SystemLogs = $GetSystemLogs

}

here is my counter:-

New-UDCounter -Title “System Logs” -TextSize Large -Endpoint {
$(($Cache:SystemLogs).count) | ConvertTo-Json
}

I’m a little bit puzzled here my understanding is this should work but it displays 0