Skip to content

Instantly share code, notes, and snippets.

@zippy1981
zippy1981 / Create-Mdb.ps1
Created August 23, 2011 21:45
A powershell script that demonstrates using PInvoke to create an access database.
# Copyright (c) 2011 Justin Dearing <zippy1981@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
@zippy1981
zippy1981 / DisplayImage.ps1
Created May 13, 2011 02:20
Display an image from Windows Powershell
# Loosely based on http://www.vistax64.com/powershell/202216-display-image-powershell.html
[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
$file = (get-item 'C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg')
#$file = (get-item "c:\image.jpg")
$img = [System.Drawing.Image]::Fromfile($file);
# This tip from http://stackoverflow.com/questions/3358372/windows-forms-look-different-in-powershell-and-powershell-ise-why/3359274#3359274
@zippy1981
zippy1981 / Get-OleDbProviders.ps1
Created August 23, 2011 10:48
Enumerates through the registry to list OleDb providers.
# Based Loosely on this VB script using a commercial ActiveX object to interrogate the registry.
# http://www.motobit.com/help/regedit/sa117.htm
Get-ChildItem HKLM:\SOFTWARE\Classes\CLSID | ForEach-Object {
$regKey = $_;
if ($regKey.GetValue('OLEDB_SERVICES') -ne $null -and $regKey.OpenSubKey("OLE DB Provider") -ne $null) {
New-Object PSObject -Property @{
'Key' = $regKey.GetValue("");
'OLEDBProvider' = $regKey.OpenSubKey("OLE DB Provider").GetValue("");
};
}
@zippy1981
zippy1981 / SOS.ino
Created April 22, 2012 20:32
Arduino SOS Program
/*
SOS
Sends SOS in morse code on the Arduino board.
For more information see http://en.wikipedia.org/wiki/Morse_code
Copyright 2012 Justin Dearing.
*/
int dotDur = 125;
int dashDur = dotDur * 3;
@zippy1981
zippy1981 / DeepCopyTest.ps1
Created March 9, 2012 14:54
PowerShell Deepcopy demo
# Get original data
$data = @{
First = 'Justin';
Last = 'Dearing';
Resume = @{
Experience = [HashTable[]]@(
@{
StartDate = [DateTime] (Get-Date '2002-03-23');
EndDate = [DateTime] (Get-Date '2007-05-15');
Company = 'ACME ISP';
@zippy1981
zippy1981 / MongoTest.ps1
Created March 4, 2011 16:27
Example of using the 10gen MongoDB CSharp driver in powershell.
# We assume that the driver is installed via the MSI.
[string] $mongoDriverPath;
# Check to see if we are running the 64 bit version of Powershell.
# See http://stackoverflow.com/questions/2897569/visual-studio-deployment-project-error-when-writing-to-registry
if ([intptr]::size -eq 8) {
$mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.0").'(default)';
}
else {
$mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 1.0").'(default)';
@zippy1981
zippy1981 / Objectid.js
Created January 14, 2011 21:09
Javascript object class for dealing with ObjectIds as JSON serialized by WCF
/*
*
* Copyright (c) 2011 Justin Dearing (zippy1981@gmail.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) version 2 licenses.
* This software is not distributed under version 3 or later of the GPL.
*
* Version 1.0.0-RC1
*
*/
@zippy1981
zippy1981 / Get-DComErrors.ps1
Last active September 18, 2018 18:50
Retrieve DCOM Errors from the Event Log
function Get-ComNameByAppId {
param (
[Guid] $AppId
)
(get-wmiobject -class "Win32_DCOMApplication" -namespace "root\CIMV2" -Filter "AppID = '{$AppId}'").Name
}
Get-EventLog -EntryType Error -LogName System |Where EventID -eq 10016 | % {
$ReplamentStringLength = $_.ReplacementStrings.Length;
$ClassId = $null;
@zippy1981
zippy1981 / RequestTelemetryEnhancingMiddleware.cs
Created June 6, 2018 15:17
Example Application Insights RequestTelemetry enhancement.
public static IApplicationBuilder UseCorrelationProperties(this IApplicationBuilder app)
{
return app.Use(async (context, next) =>
{
var logger = context.RequestServices.GetRequiredService<ILogger<CorrelationProperties>>();
// NOTE: We're using Features and not RequestServices here.
var requestTelemetry = context.Features.Get<RequestTelemetry>();
if (requestTelemetry != null)
{
@zippy1981
zippy1981 / .gitignore
Created October 9, 2011 13:28
Powershell Scripts to load evetlogs into mongodb and then query them
*~