This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tweetJson = (Get-Content .\tweets.js -Raw).Substring("window.YTD.tweets.part0 =".Length) | |
$tweets = $tweetJson | ConvertFrom-Json | |
$currentThread = "" | |
foreach($currentTweetJson in $tweets) | |
{ | |
$currentTweet = $currentTweetJson.tweet | |
if($currentTweet.in_reply_to_screen_name -eq "Lee_Holmes") | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## PowerShell Eventing lets you tail an event log: | |
## http://powershellcookbook.com/recipe/IMyz/respond-to-automatically-generated-events | |
$watcher = New-Object System.Diagnostics.Eventing.Reader.EventLogWatcher "Microsoft-Windows-PowerShell/Operational" | |
Register-ObjectEvent $watcher EventRecordWritten -Action { | |
$event = $eventArgs.EventRecord | |
if($event.ProcessId -ne $pid) | |
{ | |
## Save the last event into a variable in the PowerShell sesssion if you want to explore its properties, | |
## as the eventing actions run in their own runspace | |
# $GLOBAL:lastEvent = $event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Event | |
| where EventID == "4104" | |
| extend ParsedEvent = parse_xml(strcat("<root>", ParameterXml, "</root>")) | |
| extend MessageNumber = tolong(ParsedEvent.root.Param[0]) | |
| extend MessageTotal = tolong(ParsedEvent.root.Param[1]) | |
| extend ScriptBlockElement = iff( | |
strlen(tostring(ParsedEvent.root.Param[2]["#text"])) > 0, | |
ParsedEvent.root.Param[2]["#text"], | |
ParsedEvent.root.Param[2]) | |
| extend ScriptBlockId = tostring(ParsedEvent.root.Param[3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Received: from CY4PR21MB0742.namprd21.prod.outlook.com (2603:10b6:a03:12b::16) | |
by BYAPR21MB1208.namprd21.prod.outlook.com with HTTPS via | |
BYAPR07CA0075.NAMPRD07.PROD.OUTLOOK.COM; Fri, 3 Apr 2020 13:36:47 +0000 | |
ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; | |
b=FJkBxtEkCsT4VnSRJQ8yfPQ/lxlpLgu8AkfnnaMgnYyapQUH46RbVqXvhcoQO2eCvbpDf3Y855zQ9tmjmYqAuXauEDYFwuTuGzpTTl4k50TeFFwUUoY+3ZprT9HHM5xL/XpwIep31XSVu8hdRbTfysbONe3B18Who0HBUY6flZOqRcGt0qtWqumhwR93tfyrhKfvG7QWE4etvnIZx4ngs29usfjUjTPNJqD98Y4JaeNfBneEhE61x1wLzEaIQ12AJ6MtZn+lbJGBPfgaVAQ0zhpyIsXMi9KkXVaFN1sh9PzNWLatNJ1Ersx06d5dqlA98pPUJgeFb0kTfam7BHgGow== | |
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; | |
s=arcselector9901; | |
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; | |
bh=/HplSl9WQXo7X7X+V7lZVdH9hhQ5Nxt3DDHJ7t8uVwE=; | |
b=cRE9xpH8u43eExuoXIZpSVVxkANS5xx91mlgh2vvW79uHBM41YrCoLJjNMl3nJIpaItvnl41D7nbbQoVUMNz32TIWfXp5w9vSZOePvKeAqIeAXy/o6mj5XNZSjEN7k2zxx+qh3hDVlwwSVtGGMK5Al64N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[ScriptBlock] $ScriptBlock | |
) | |
function Invoke-Expression | |
{ | |
param( | |
[Parameter(Position = 0, ValueFromPipeline = $true)] | |
[String] $__InputObject | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$historyItem = Get-History -Count 1 | |
$id = 1 | |
if($historyItem) | |
{ | |
$id = $historyItem.Id + 1 | |
## Check if the last command took a long time | |
if(($historyItem.EndExecutionTime - $historyItem.StartExecutionTime).TotalSeconds -gt 3) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Not measurably faster. Doing this via Add-Type or direct PowerShell still takes about 4 seconds per megabyte. | |
function Get-Entropy | |
{ | |
<# | |
.SYNOPSIS | |
Calculate the entropy of a byte array. | |
Derived from Get-Entropy by Matthew Graeber (@mattifestation) |