Skip to content

Instantly share code, notes, and snippets.

View kekoa-'s full-sized avatar

Chris Akina kekoa-

View GitHub Profile
@kekoa-
kekoa- / Delete-NetworkPrinters.ps1
Created August 15, 2020 19:22
uses wmi to delete all network printers
Get-WMIObject Win32_Printer | Where-Object { $_.Network -eq 'true' } | Foreach-Object { $_.delete() }
@kekoa-
kekoa- / gist:cd39806ef056aeef5da63b9e0ba2393b
Created March 1, 2020 05:56 — forked from jacksonfdam/gist:3000275
Regular Expressions List
//Regular Expressions List
//Short Tutorial
\ // the escape character - used to find an instance of a metacharacter like a period, brackets, etc.
. // match any character except newline
x // match any instance of x
^x // match any character except x
[x] // match any instance of x in the bracketed range - [abxyz] will match any instance of a, b, x, y, or z
| // an OR operator - [x|y] will match an instance of x or y
@kekoa-
kekoa- / Import-Excel.ps1
Created March 1, 2020 05:52 — forked from ellisgeek/Import-Excel.ps1
Import Excel file into powershell in a manner compatible with Import-Csv
function Import-Excel {
<#
.SYNOPSIS
Creates table-like custom objects from the items in a Excel file.
Requires Excel be installed!
.DESCRIPTION
The Import-Excel cmdlet creates table-like custom objects from the items in Excel
Worksheets.
Each column in the Excel Worksheet becomes a property of the custom object and the items in
rows become the property values. Import-Excel works on any file supported by Excel.
@kekoa-
kekoa- / Get-ModuleVersionReport.ps1
Created September 24, 2019 23:07
Returns installed modules and uses color to indicate when multiple versions are installed Source: http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules/
# See what modules are installed -- lists multiple versions too
# Source: http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules/
Write-Host "this will report all modules with duplicate (older and newer) versions installed"
Write-Host "be sure to run this as an admin" -foregroundcolor yellow
Write-Host "(You can update all your Azure RMmodules with update-module Azurerm -force)"
$mods = Get-InstalledModule
foreach ($Mod in $mods) {
@kekoa-
kekoa- / Get-ModuleVersionReport.ps1
Created September 24, 2019 23:07
Returns installed modules and uses color to indicate when multiple versions are installed Source: http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules/
# See what modules are installed -- lists multiple versions too
# Source: http://sharepointjack.com/2017/powershell-script-to-remove-duplicate-old-modules/
Write-Host "this will report all modules with duplicate (older and newer) versions installed"
Write-Host "be sure to run this as an admin" -foregroundcolor yellow
Write-Host "(You can update all your Azure RMmodules with update-module Azurerm -force)"
$mods = Get-InstalledModule
foreach ($Mod in $mods) {
@kekoa-
kekoa- / SQL Server Dynamic Pivot Demo.sql
Created January 1, 2019 23:16
This script demonstrates using dynamic SQL to build PIVOT reports.
-- SQL Server Dynamic Pivot Demo
-- Disclaimer
-- Part of this script is based on PIVOT samples I found somewhere on the net,
-- though most of this is my own work.
------------------------------------------------------------------------
-- FIRST PHASE: Set up demo data in a table called dbo.MonthlySales
------------------------------------------------------------------------
# Originally published at https://gist.github.com/nzthiago/5736907
# I Customized it for SPC14 with slides
# If you like it, leave me a comment
# If you don't like it, complain to Github. :)
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$rss = (new-object net.webclient)
# Grab the RSS feed for the MP4 downloads
@kekoa-
kekoa- / sshsync.ps1
Created March 27, 2018 22:47
Sync changes to local filesystem via SSH (Powershell)
param (
[string]$searchPath = "",
[string]$puttySession = "",
[string]$destPath = ""
)
#
# Init
#
@kekoa-
kekoa- / getCurrentExternalIPAddress.ps1
Created March 27, 2018 22:43 — forked from rayterrill/getCurrentExternalIPAddress.ps1
PowerShell - Get Current External IP Address
#h/t: http://tfl09.blogspot.com/2008/07/finding-your-external-ip-address-with.html
function getCurrentExternalIPAddress() {
$wc=New-Object net.webclient
$wc.downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]"
}
@kekoa-
kekoa- / DynamicSqlParser.vb
Created March 12, 2018 15:49
Dynamic SQL parser and sample SQL statement (StringBuilder extension method source code can be found at <script src="https://gist.github.com/kekoa-/dfdbafbcfa2bea6d44582bd2e56b682c.js"></script>
Imports System.Text.RegularExpressions
Imports System.Text
''' <summary>
'' 'Dynamic SQL parser
''' </summary>
''' <remarks></remarks>
Public Class DynamicSqlParser
''' <summary>
'' 'Create the DB command