Skip to content

Instantly share code, notes, and snippets.

View jdhitsolutions's full-sized avatar

Jeff Hicks jdhitsolutions

View GitHub Profile
@jdhitsolutions
jdhitsolutions / Get-ISEMru.ps1
Created December 6, 2016 15:18
A PowerShell function to get the most recent used list. Note that this list isn't updated until you close the ISE.
Function Get-ISEMRU {
[cmdletbinding()]
Param()
<#
Path will be something like:
C:\Users\Jeff\AppData\Local\microsoft_corporation\powershell_ise.exe_StrongName_lw2v2vm3wmtzzpebq33gybmeoxukb04w
#>
$ISEPath = "$env:localappdata\microsoft_corporation\powershell_ise*\3.0.0.0"
@jdhitsolutions
jdhitsolutions / myBook.ps1
Created January 26, 2017 15:33
demo PowerShell class script
Enum BookCategory {
GeneralFiction
Horror
Romance
Literary
Mystery
Thriller
ScienceFiction
NonFiction
@jdhitsolutions
jdhitsolutions / Test-MyWsMan.ps1
Last active February 13, 2017 23:37
A modified version of Test-WsMan that supports -Quiet and other minor improvements.
#requires -version 4.0
#requires -module Microsoft.WSMan.Management
<#
This is a copy of:
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Test-WSMan 3.0.0.0 Microsoft.WSMan.Management
@jdhitsolutions
jdhitsolutions / Demo-InformationFunctions.ps1
Created January 23, 2017 18:27
Demos of the PowerShell information stream
#requires -version 5.0
Function Test-Me {
[cmdletbinding()]
Param()
Write-Information "Starting $($MyInvocation.MyCommand) " -Tags Process
Write-Information "PSVersion = $($PSVersionTable.PSVersion)" -Tags Meta
Write-Information "OS = $((Get-CimInstance Win32_operatingsystem).Caption)" -Tags Meta
@jdhitsolutions
jdhitsolutions / Download-ToddKlindt.ps1
Created May 15, 2017 18:50
A PowerShell script to download video podcasts from Todd Klindt
#Requires -version 4.0
<#
This is a script but it supports -Whatif and accepts parameters.
#>
[cmdletbinding(SupportsShouldProcess)]
Param (
[Parameter(Position = 0, HelpMessage = "Enter the path where you want to save the downloads")]
@jdhitsolutions
jdhitsolutions / Anagrams.ps1
Last active June 24, 2017 11:00
A PowerShell function to find anagrams from a word list.
#you will need a text file of words like this list from https://github.com/dwyl/english-words
Function Get-Anagram {
[cmdletbinding()]
Param(
[Parameter(Position = 0, Mandatory)]
[ValidateNotNullorEmpty()]
[Alias("word")]
[string]$Text,
@jdhitsolutions
jdhitsolutions / New-StarWarsName.ps1
Last active December 1, 2017 15:58
Generate a fictious name that might exist in the Star Wars universe.
#generate a fictious name that might exist in the Star Wars universe.
[cmdletbinding()]
Param(
[Parameter(Mandatory,HelpMessage="Enter your first name. It must be at least 2 characters")]
[ValidateNotNullOrEmpty()]
[ValidateScript({$_.length -ge 2})]
[String]$Name,
[Parameter(Mandatory,HelpMessage="Enter your Mother's first name. It must be at least 2 characters")]
[ValidateNotNullOrEmpty()]
@jdhitsolutions
jdhitsolutions / PSHanukkahPrompt.ps1
Last active December 5, 2017 16:47
PowerShell Prompt to Countdown Hanukkah
#this prompt counts down to the first day of Hanukkah 2017
<#
It appears that some of the special characters I was using aren't supported in Windows 10 unless you are using Raster fonts.
[CHAR]14 is supposed to be a musical note and [CHAR]15 is like a snowflake.
You can select any other character you want, or none at all.
#>
Function Prompt {
#get current year
$year = (Get-Date).year
@jdhitsolutions
jdhitsolutions / ISEToDo.ps1
Created July 1, 2016 14:41
Add a menu shortcut in the PowerShell ISE to insert a dated ToDo comment
#Insert a ToDo comment in an ISE script file
$action = {
$psise.CurrentFile.Editor.InsertText("# [$((Get-Date).ToShortDateString())] ToDo: ")
#jump cursor to the end
$psise.CurrentFile.editor.SetCaretPosition($psise.CurrentFile.Editor.CaretLine,$psise.CurrentFile.Editor.CaretColumn)
}
#add the action to the Add-Ons menu
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("ToDo",$Action,"Alt+2" ) | Out-Null
@jdhitsolutions
jdhitsolutions / Out-More.ps1
Last active December 14, 2017 19:17
A function to pipe objects to the pipeline and console in groups or pages.
#requires -version 4.0
Function Out-More {
<#
.Synopsis
Send "pages" of objects to the pipeline.
.Description
This function is designed to display groups or "pages" of objects to the PowerShell pipeline. It is modeled after the legacy More.com command line utility.
By default the command will write out objects out to the pipeline in groups of 50. You will be prompted after each grouping. Pressing M or Enter will get the next group. Pressing A will stop paging and display all of the remaining objects. Pressing N will display the next object. Press Q to stop writing anything else to the pipeline.