Skip to content

Instantly share code, notes, and snippets.

@joshuatee
joshuatee / Client.cs
Created September 7, 2016 08:26 — forked from leandrosilva/Client.cs
Asynchronous Client/Server Socket Example with C# (from MSDN library)
// Asynchronous Client Socket Example
// http://msdn.microsoft.com/en-us/library/bew39x2a.aspx
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
// State object for receiving data from remote device.
@joshuatee
joshuatee / ToastNotification-Sample.ps1
Created May 28, 2016 23:04 — forked from guitarrapc/ToastNotification-Sample.ps1
toast sample in PowerShell not yet finished;
# Code conversion from C# to PowerShell
# http://msdn.microsoft.com/en-us/library/windows/apps/hh802768.aspx
# nuget Windows 7 API Code Pack -Shell
# http://nugetmusthaves.com/Package/Windows7APICodePack-Shell
# Install-Package Windows7APICodePack-Shell
Add-Type -Path .\Microsoft.WindowsAPICodePack.dll
Add-Type -Path .\Microsoft.WindowsAPICodePack.Shell.dll
# create toast template TO xml
# getting bound parameters that are NOT common parameters
function Verb-Noun
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[string]
$Param1,
@joshuatee
joshuatee / Invoke-ElevatedCommand.ps1
Created December 8, 2015 21:57 — forked from TaoK/Invoke-ElevatedCommand.ps1
Invoke-ElevatedCommand for Administrator-level commands in a common powershell pipeline
Function Invoke-ElevatedCommand {
<#
.DESCRIPTION
Invokes the provided script block in a new elevated (Administrator) powershell process,
while retaining access to the pipeline (pipe in and out). Please note, "Write-Host" output
will be LOST - only the object pipeline and errors are handled. In general, prefer
"Write-Output" over "Write-Host" unless UI output is the only possible use of the information.
Also see Community Extensions "Invoke-Elevated"/"su"
.EXAMPLE
@joshuatee
joshuatee / Invoke-Fiddler.ps1
Created November 29, 2015 14:14
Fiddler Using PowerShell
<#
Assumes that Fiddler Core Libraries are in same directory as this script.
http://www.telerik.com/fiddler/fiddlercore
This script uses Fiddler Core 4
#>
function Start-Fiddler {
<#
.Synopsis
Uses FiddlerCore to listen on a specified port.
@joshuatee
joshuatee / Send-NetworkData.ps1
Created November 28, 2015 19:46 — forked from jstangroome/Send-NetworkData.ps1
A simple PowerShell implementation of the most basic functionality of Netcat
function Send-NetworkData {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$Computer,
[Parameter(Mandatory)]
[ValidateRange(1, 65535)]
[Int16]
[CmdletBinding()]
[OutputType([System.Management.Automation.PSModuleInfo])]
param(
# The name of the module to install from GitHub.
[Parameter(Position=0, Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[System.String[]]
$ModuleName,
# The scope from which the module should be discoverable.
@joshuatee
joshuatee / import-portatour.ps1
Created November 6, 2015 02:49 — forked from weipah/import-portatour.ps1
PowerShell V3 Multipart/formdata example with REST-API (Invoke-RestMethod)
function Import-Portatour {
param (
[parameter(Mandatory=$True,Position=1)] [ValidateScript({ Test-Path -PathType Leaf $_ })] [String] $FilePath,
[parameter(Mandatory=$False,Position=2)] [System.URI] $ResultURL
)
# CONST
$CODEPAGE = "iso-8859-1" # alternatives are ASCII, UTF-8
# We have a REST-Endpoint
$RESTURL = "https://my.portatour.net/a/api/ImportCustomers/"