Skip to content

Instantly share code, notes, and snippets.

@JohnL4
Last active February 25, 2025 18:14
Show Gist options
  • Save JohnL4/95a02aab6a80057be7454167cd593fca to your computer and use it in GitHub Desktop.
Save JohnL4/95a02aab6a80057be7454167cd593fca to your computer and use it in GitHub Desktop.
Use a remote session to pull info out of a remote file
# Casting hashtable to PSCustomObject must be on one line, afaict.
# -split uses regexp, so '|' must be escaped
icm { cd f:\DataPump/logs; cat ImportData2Snowflake_20250224.log, ImportData2Snowflake_20250225.log | sls '\| Destination:' | % {
$arr = $_ -split ' \| ';
[PSCustomObject] @{TimeStamp = get-date $arr[0]; Note = $arr[5]; FieldCount = $arr.Count; FullText=$_ }
} | ? {$_.TimeStamp -ge (get-date '2025-02-24T22:00+00:00')} } -session $ses | select TimeStamp,Note | ft -au -wr
# Could also use just 'cat -tail 200 -wait' to tail the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment