Skip to content

Instantly share code, notes, and snippets.

###### STEP 1 - Get GIT Credentials
$EncryptedPasswordString = "Your Encrypted Github Password String"
$Args = "Your Github Username", ($EncryptedPasswordString |ConvertTo-SecureString)
$GitCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Args
# Required Functions
Function Update-AllPowerShellProfile
{
$ProfileDirectory = "$env:USERPROFILE\Documents\WindowsPowerShell\"
$AllPSPRofiles = dir $ProfileDirectory | ?{$_.name -like "*Profile*"} | sort LastWriteTime -Descending
@ksumrall
ksumrall / get-last-commit-summary.ps1
Last active October 10, 2018 15:37
Get last commit summary of remote branches
(git branch -r) | % { git log -n 1 --format="%d`t%h`t%cd`t%an`t'%s'" $_.trim() -- } | Set-Content -Path "output.csv"
@ksumrall
ksumrall / cleanup-local-git-branches.ps1
Last active September 27, 2018 20:20
Powershell command for cleaning up local git branches
# for viewing the matching branches
git branch -vv | foreach { if($_ -match "^\s{2}([^\s]+).+?: gone]"){ Write-Host $matches[1] } }
# to delete the branches
git branch -vv | foreach { if($_ -match "^\s{2}([^\s]+).+?: gone]"){ git branch -d $matches[1] } }
@ksumrall
ksumrall / ConvertTo-PSON.ps1
Created July 23, 2018 16:56 — forked from Chirishman/ConvertTo-PSON.ps1
Convert to PowerShell Object Notation
function ConvertTo-PSON {
<#
.SYNOPSIS
Generates a PowerShell object-notation in the style of a PSD1 document
.DESCRIPTION
This stringifies a PowerShell object following the style of a PSD1 document, the powerShell-equivalent of JSON. The behavior is incomplete but works fine for simple objects.
.EXAMPLE
$array=@()
$array+=Get-Process wi* | Select-Object Handles,NPM,PM,WS,VM,CPU,Id,ProcessName
ConvertTo-PSON $array
@ksumrall
ksumrall / Merge-Json.ps1
Last active December 11, 2019 19:50 — forked from Badabum/Merge-Json.ps1
Merge two .json objects using PowerShell
function Join-Objects($source, $extend){
if($source.GetType().Name -eq "PSCustomObject" -and $extend.GetType().Name -eq "PSCustomObject"){
foreach($Property in $source | Get-Member -type NoteProperty, Property){
if($extend.$($Property.Name) -eq $null){
continue;
}
$source.$($Property.Name) = Join-Objects $source.$($Property.Name) $extend.$($Property.Name)
}
}else{
$source = $extend;
@ksumrall
ksumrall / join.ps1
Created July 5, 2018 13:48 — forked from jehugaleahsa/join.ps1
PowerShell Script to Split Large Files
function join($path)
{
$files = Get-ChildItem -Path "$path.*.part" | Sort-Object -Property @{Expression={
$shortName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
$extension = [System.IO.Path]::GetExtension($shortName)
if ($extension -ne $null -and $extension -ne '')
{
$extension = $extension.Substring(1)
}
[System.Convert]::ToInt32($extension)
using System;
using System.Globalization;
using System.Net;
using System.Security.Cryptography;
using System.Text;
public class GoogleAuthenticator
{
const int IntervalLength = 30;
const int PinLength = 6;