Powershell Get Custom Event Logs Function

Did you ever wish there was a fast and efficient way to retrieve event logs from a remote machine?  Enter Get-CustomEventLogs function.  Below is a simple function that allows you to quickly query a remote machine by name, logname, and timeframe (0-744 hours which is 31 days).  The results will be returned to the console.  This function can be piped to other outputs as well.  Try Get-CustomEventsLogs | Out-GridView for a quick way to scroll through events.

Function Get-CustomEventsLogs
$logtime = (Get-Date) - (New-TimeSpan -Hours $StartTime)
Get-WinEvent -filterhashtable @{LogName=$logname; StartTime=$logtime} -Computername $Server | where {$_.TimeCreated -ge $logtime} | select message,id,recordid,providername,logname,machinename,userid,timecreated,containerlog,leveldisplayname