This file contains hidden or 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
$Tables = @() | |
$Tables += Get-Process | ConvertTo-Html -Fragment | Out-String | |
$Tables += Get-Service | ConvertTo-Html -Fragment | Out-String | |
$Tables += Get-ChildItem $env:SystemDrive\Users | ConvertTo-Html -Fragment | Out-String | |
$Tables += Get-ChildItem HKLM:\SOFTWARE\ODBC\ODBC.INI | ConvertTo-Html -Fragment | Out-String | |
$Head = @" | |
<!doctype html> | |
<html> |
This file contains hidden or 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
# load the appropriate assemblies | |
[void][Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) | |
[void][Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms.DataVisualization”) | |
# create chart object | |
$Chart = New-object System.Windows.Forms.DataVisualization.Charting.Chart | |
$Chart.Width = 500 | |
$Chart.Height = 400 | |
$Chart.Left = 40 | |
$Chart.Top = 30 |
This file contains hidden or 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
$Parameters = @{ | |
a = '{14}' | |
b = '{22}' | |
} | |
$UrlParameters = ($Parameters.Keys | ForEach-Object { | |
"{0}={1}" -f [System.Web.HttpUtility]::UrlEncode($_), [System.Web.HttpUtility]::UrlEncode($Parameters[$_]) | |
}) -join "&" | |
$Uri = "https://<rootURI>/calc/add?$UrlParameters" |
This file contains hidden or 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
# Keeping this scratch ISE data. The WMI time conversion may be of interest (see also [Management.ManagementDateTimeConverter]::ToDateTime() ) | |
# filterxml and filterxpath from https://www.reddit.com/r/PowerShell/comments/5hgr1g/help_getwinevent_filterxml_i_dont_get_it/ may also be of interest | |
$ElevenDaysAgo = [Management.ManagementDateTimeConverter]::ToDmtfDateTime((Get-Date ) - (New-TimeSpan -Days 11)) | |
$ElevenDaysAgo = [Management.ManagementDateTimeConverter]::ToDmtfDateTime((Get-Date -Hour 0 -Minute 0 -Second 0 -Millisecond 0) - (New-TimeSpan -Days 11)) | |
# Get-WmiObject -Class win32_ntlogevent -Filter "(logfile='System') and (SourceName='Microsoft-Windows-Winlogon') and (TimeGenerated > '$ElevenDaysAgo')" | |
Get-CimInstance -Class win32_ntlogevent -Filter "(logfile='System') and (SourceName='Microsoft-Windows-Winlogon') and (TimeGenerated > '$ElevenDaysAgo')" | |
break |
This file contains hidden or 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
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
# This is how I upload my new Sol Trader builds (http://soltrader.net) | |
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
S3KEY="my aws key" | |
S3SECRET="my aws secret" # pass these in | |
function putS3 | |
{ | |
path=$1 |
This file contains hidden or 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
<# | |
I've been having trouble getting the "Open in Code" Explorer context menus | |
to appear for Visual Studio Code. I think the problem is permissions on | |
the HKEY_CLASSES_ROOT\*\shell\VSCode reg key because I can see it as | |
admin but not as a user. (My admin accounts are different than my user | |
accounts.) | |
Setting these two keys/three properties in HKCU makes it work for me and | |
doesn't require admin permissions, so I made this rather than run the | |
reg scripts I'm seeing online. |
This file contains hidden or 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
# Given an array of rss xml document objects, return one rss document object with all the items sorted by date, descending | |
# Because of auto-deserialization, may need to build xml doc arrays with @(,$XmlDoc) trick | |
function Invoke-CombineRssXml { | |
[cmdletbinding()] | |
param ( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)] | |
[xml[]]$Xml | |
) | |
begin { | |
Write-Verbose "Combining rss xml documents" |
This file contains hidden or 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
# Based on http://www.powershellmagazine.com/2015/05/12/natively-query-csv-files-using-sql-syntax-in-powershell/ | |
$csv = "$PSScriptRoot\test.csv" | |
$firstRowColumnNames = "Yes" | |
$delimiter = "," | |
$provider = (New-Object System.Data.OleDb.OleDbEnumerator).GetElements() | Where-Object { $_.SOURCES_NAME -like "Microsoft.ACE.OLEDB.*" } | |
if ($provider -is [system.array]) { $provider = $provider[0].SOURCES_NAME } else { $provider = $provider.SOURCES_NAME } | |
$connstring = "Provider=$provider;Data Source=$(Split-Path $csv);Extended Properties='text;HDR=$firstRowColumnNames;';" |
This file contains hidden or 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
$NinjaJs = @" | |
var NinjaQuerySelectorAll = function(selector) { | |
nodeList = document.querySelectorAll(selector); | |
output = []; | |
for (i=0; i < nodeList.length; i++) output.push(nodeList.item(i)); | |
console.log("Ninja JS function output"); | |
console.log(output); | |
return output; | |
} | |
"@ |
This file contains hidden or 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
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | |
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | |
# I hate Write-Host, but the console output stream is uncoupled from the form, so we'll do this for illustration | |
function Write-MyOutput ($x) { | |
Write-Host "Entered Text: $x" | |
} | |
$objForm = New-Object System.Windows.Forms.Form | |
$objForm.Text = "Data Entry Form" |