Skip to content

Instantly share code, notes, and snippets.

View jdhitsolutions's full-sized avatar

Jeff Hicks jdhitsolutions

View GitHub Profile
@jdhitsolutions
jdhitsolutions / Update-VMNote.ps1
Last active September 23, 2022 22:40
A PowerShell function to get Windows system information from a Hyper-V VM and update the VM's Note with it. First described at http://bit.ly/1OtGxxD.
#requires -version 4.0
#requires -module Hyper-V
Function Update-VMNote {
<#
.Synopsis
Update the Hyper-V VM Note with system information.
.Description
This command is designed to update a Hyper-V virtual machine note, for machines running Windows on a publically accessible network, with host information like this:
@jdhitsolutions
jdhitsolutions / PSOde.ps1
Created January 23, 2016 14:37
A PowerShell music script that "speaks" for itself.
<#
1 = QUARTER NOTE
1.25 = QUARTER AND HALF
.5 = EIGHTH NOTE
.25 = SIXTEENTH NOTE
2 = HALF NOTE
#>
#<duration><note>[<octave>]
@jdhitsolutions
jdhitsolutions / PowerShellNap.ps1
Last active February 21, 2022 09:44
An advanced PowerShell function that you can use as an alarm clock while taking a nap.
#requires -Version 5.1
Function Start-PSNap {
<#
.SYNOPSIS
Start a PowerShell napping session.
.DESCRIPTION
Use this command to start a short napping session. The command will alert you when you nap is up with a chime and a message. You have an option of displaying the message on the screen or having it spoken.
@jdhitsolutions
jdhitsolutions / LocalUserInfo.ps1
Last active March 10, 2022 00:15
A PowerShell function that uses ADSI to query for local account information. Read the function help for more details.
#requires -version 3.0
<#
This function has no provision for alternate credentials unless you run
it with Invoke-Command in a PSSession.
#>
Function Get-LocalUser {
<#
@jdhitsolutions
jdhitsolutions / Update-SysinternalsWorkflow.ps1
Last active November 4, 2022 10:51
A demonstration of using a PowerShell workflow as a scripting tool to download the Sysinternals suite of tools.
#requires -version 4.0
#https://gist.github.com/jdhitsolutions/f0415db6bc8dc6236fb3
<#
A PowerShell workflow to download Sysinternals tools from web to a local folder.
Last updated: February 15, 2016
version : 2.1
@jdhitsolutions
jdhitsolutions / Get-LocalGroupMember.ps1
Last active December 13, 2022 23:13
A PowerShell function to list members of a local group such as Administrators.
#requires -version 4.0
Function Get-LocalGroupMember {
<#
.SYNOPSIS
Get local group membership using ADSI.
.DESCRIPTION
This command uses ADSI to connect to a server and enumerate the members of a local group. By default it will retrieve members of the local Administrators group.
@jdhitsolutions
jdhitsolutions / Get-LocalGroupMember2.ps1
Last active March 15, 2022 20:52
A revised version of my Get-LocalGroupMember function that has options to use PowerShell remoting.
#requires -version 4.0
Function Get-LocalGroupMember {
<#
.SYNOPSIS
Get local group membership using ADSI.
.DESCRIPTION
@jdhitsolutions
jdhitsolutions / Add-ISESelectLineShortcut.ps1
Last active June 8, 2016 18:24
Add a menu shortcut to the PowerShell ISE to select the current line.
#add an ISE shortcut to select the current line
#put this in your ISE profile script
<#
Microsoft.PowerShell.Host.ISE.ISEMenuItem Add(
string displayName,
scriptblock action,
System.Windows.Input.KeyGesture shortcut
)
@jdhitsolutions
jdhitsolutions / StPatPrompt.ps1
Last active March 17, 2016 15:17
A St. Patrick's Day themed PowerShell Prompt
#edited for clarity.
function prompt {
$message = "$([char]9827) Éirinn go Brách $([char]9827) "
write-host $message -ForegroundColor green -NoNewline
"$((Get-Location).Path)>"
}
@jdhitsolutions
jdhitsolutions / ConvertTo-HTMLListing.ps1
Created May 9, 2016 11:42
This command will take the contents of a text file and create an HTML document complete with line numbers.
#requires -version 3.0
Function ConvertTo-HTMLListing {
<#
.Synopsis
Convert text file to HTML listing
.Description
This command will take the contents of a text file and create an HTML document complete with line numbers. The command does not create an actual file. You would need to pipe to Out-File. See examples.
There are options to suppress the line numbers and to skip any blank lines. The command is intended to convert one file at a time although you can pipe a file name to the command.