Skip to content

Instantly share code, notes, and snippets.

View JPRuskin's full-sized avatar

James Ruskin JPRuskin

View GitHub Profile
@JPRuskin
JPRuskin / ConvertTo-OTBStyle.ps1
Last active June 29, 2017 11:43
Converts a given script or directory of PS1 files to One True Brace Style formatting.
function ConvertTo-OTBStyle {
#Requires -Modules @{ModuleName='PSScriptAnalyzer';ModuleVersion='1.15.0'}
[CmdletBinding()]
param(
[Parameter(Mandatory, ParameterSetName = 'Directory')]
[ValidateScript( {Test-Path -Path $_ -PathType Container})]
[IO.DirectoryInfo]$Directory,
[Parameter(ParameterSetName = 'Directory')]
[Switch]$Recurse,
@JPRuskin
JPRuskin / Remove-LocalTFSFolders.ps1
Last active July 19, 2017 16:29
Quick method for removing all Release folders from a given local workspace
function Update-LocalTFSFolder {
[CmdletBinding()]
param(
[ValidateScript({Test-Path $_ -Include "tf.exe" -Type Leaf})]
$TF = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\TF.exe",
[Parameter(ValueFromPipeline,Mandatory,ParameterSetName='Path')]
[String]$Path,
[Parameter(ValueFromPipelineByPropertyName,Mandatory,ParameterSetName='FullName')]
@JPRuskin
JPRuskin / Pok3r.ahk
Created August 30, 2017 14:46 — forked from JarvisPrestidge/Pok3r.ahk
Personal AutoHotKey script that turns any keyboard into a Pok3r.
#CommentFlag //
#InstallKeybdHook
// Author: Jarvis Prestidge
// Description: Simulates my preferred keyboard layout, similiar to that of the Pok3r 60% keyboard
// on any keyboard without programmable keys. i.e. my laptop ^^
// <COMPILER: v1.1.22.00>
@JPRuskin
JPRuskin / download-module.ps1
Created September 25, 2017 13:53
Download modules from PSGallery
function Download-Module {
[CmdletBinding()]
param(
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[String[]]$Name,
[Parameter(ValueFromPipelineByPropertyName)]
[String]$Repository,
[PSCredential]$Credential,
@JPRuskin
JPRuskin / jiggle.ahk
Created April 11, 2018 18:08
Jiggles the cursor periodically
min = 1
loop {
sleep, % min*60*1000
mousemove, 10, 0, 20, R
sleep, % 1000
mousemove, -10, 0, 20, R
sleep, % 1000
mousemove, 10, 0, 20, R
sleep, % 1000
@JPRuskin
JPRuskin / StringToTitleCase.ps1
Created May 2, 2018 11:01
Adds a ScriptMethod to strings, .ToTitle(). Converts to title case.
Update-TypeData -TypeName String -MemberType ScriptMethod -MemberName ToTitle -Force -Value {
(Get-Culture).TextInfo.ToTitleCase($this)
}
@JPRuskin
JPRuskin / Get-ScriptRequirements.ps1
Created August 24, 2018 14:21
Function to get all commands called in a given script, scriptblock, or command, and display them along with the module they are contained in.
#function Get-ScriptRequirements {
<#
.SYNOPSIS
Gets all calls within a script or scriptblock and outputs name, module and count.
.DESCRIPTION
Uses AST to retrieve all calls in a valid script file, command, or
scriptblock, then outputs the amount of each along with the module
.EXAMPLE
### Keybase proof
I hereby claim:
* I am jpruskin on github.
* I am jpruskin (https://keybase.io/jpruskin) on keybase.
* I have a public key ASBSOojCinFMzkuH-Gj20s5k77xK5v7w6HRSLi8EaCblcgo
To claim this, I am signing this object:
param(
$LessThan = 5,
$ForMinutes = 5
)
$Continuing = $true
$NetBytes = '\Network Interface(*)\Bytes Received/sec'
$Count = 0
while ($Continuing) {
@JPRuskin
JPRuskin / Start-AzureLab.ps1
Created October 8, 2018 17:49
Starts all VMs in a resource group, starting VMs matching *DC1 first (by default, uses -StartOrder)
#function Start-AzureLab {
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline)]
[ArgumentCompleter({(Get-AzureRmResourceGroup).ResourceGroupName})]
[string[]]$ResourceGroupName,
[ArgumentCompleter({(Get-AzureRmSubscription).Name | % {"'$_'"}})]
[string]$SubscriptionName = (Get-AzureRmContext).Subscription.Name,