Skip to content

Instantly share code, notes, and snippets.

View jdhitsolutions's full-sized avatar

Jeff Hicks jdhitsolutions

View GitHub Profile
@jdhitsolutions
jdhitsolutions / TelemetryPrompt.ps1
Last active March 10, 2019 18:33
A PowerShell prompt function to display telemetry-like information for a few remote servers.
#requires -version 5.1
#this requires a windows platform
Function prompt {
$charHash = @{
Up = 0x25b2 -as [char]
Down = 0x25bc -as [char]
}
@jdhitsolutions
jdhitsolutions / Send-ToPSGridview.ps1
Created January 15, 2019 18:02
A PowerShell Core function designed to send output to an instance of Out-Gridview in Windows PowerShell. This requires you to be running a full graphical desktop like Windows 10.
#requires -version 6.1
Function Send-ToPSGridView {
<#
.SYNOPSIS
Send objects to Out-Gridview in Windows PowerShell
.DESCRIPTION
This command is intended as a workaround for PowerShell Core running on a Windows platform, presumably Windows 10. PowerShell Core does not support all of the .NET Framework which means some commands like Out-Gridview are not supported. However, on a Windows desktop you are most likely running Windows PowerShell side by side with PowerShell Core. This command is designed to take objects from a PowerShell expression and send it to an instance of Windows PowerShell running Out-Gridview. You can specify a title and pass objects back to your PowerShell Core session. Note that passed objects will be deserialized versions of the original objects.
.PARAMETER Title
@jdhitsolutions
jdhitsolutions / Test-IsNanoServer.ps1
Last active July 11, 2019 16:56
A PowerShell function to test if a remote computer is a Nano installation.
#Requires -version 3.0
<#
Test-IsNanoServer.ps1
****************************************************************
* DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *
* THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK. IF *
* YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *
* DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING. *
@jdhitsolutions
jdhitsolutions / EverythingPrompt.ps1
Last active July 30, 2019 23:14
A "kitchen sink" PowerShell prompt. This only works on Windows platforms, including PowerShell Core.
<#
This may not work properly or completely in all PowerShell hosts. Because the function
relies on Get-CimInstance it will not work on Linux platforms.
It is also admittedly not speedy as it is doing a lot of stuff, although there is an
attempt to cache some information which gets updated every 15 minutes.
To use, dot source this script in your PowerShell profile to make it your default prompt.
Sample prompt:
@jdhitsolutions
jdhitsolutions / BoxPrompt2.ps1
Created January 21, 2019 15:51
A variation on my PowerShell box prompt. This should work cross-platform on PowerShell Core.
#requires -version 5.1
<#
This is a variation of the BoxPrompt code you can find at https://gist.github.com/jdhitsolutions/df808116f9234c070bdaf233418ec59b
Create a lined box with user and location information. The line color will indicate if the user is running elevated.
The prompt will also display the current date and time and a PS prompt with the PowerShell version.
┌───────────────────────┐
│ [BOVINE320\Jeff] C:\ │
@jdhitsolutions
jdhitsolutions / New-Thriller-v2.ps1
Created November 16, 2018 14:13
A fun PowerShell script to generate a thriller book description from random data. Demonstrates a number of scripting techniques.
<#
Examples
PS C:\> c:\scripts\New-Thriller.ps1
Open Source
-----------
by Jack Rollins
This exciting new tale from the author of 'Patch Tuesday' and 'The Game of Death',
@jdhitsolutions
jdhitsolutions / New-WindowsTerminalProfile.ps1
Last active November 5, 2019 04:04
A proof of concept PowerShell function to add a new profile to the Windows Terminal Preview (0.2.1831.0).
Function New-WindowsTerminalProfile {
[cmdletbinding(SupportsShouldProcess)]
Param(
[Parameter(Position = 0, Mandatory)]
[ValidateNotNullOrEmpty()]
[alias("name")]
[string]$ProfileName,
[Parameter( Mandatory)]
[ValidateNotNullOrEmpty()]
@jdhitsolutions
jdhitsolutions / dailyprompt.ps1
Last active November 26, 2019 21:18
An enhanced PowerShell prompt function that incorporates some of my other PowerShell modules to provide a daily management experience.
#requires -version 5.1
<#
The complete version of the function also requires additional modules
which can be downloaded from the PowerShell Gallery.
https://github.com/jdhitsolutions/PSCalendar
https://github.com/jdhitsolutions/myTickle
If you prefer to
@jdhitsolutions
jdhitsolutions / mydockercontainer.format.ps1xml
Created April 1, 2019 17:24
A PowerShell format file to be used with my Get-DockerContainer function.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<ViewDefinitions>
<View>
<!--Created 03/27/2019 17:01:10 by BOVINE320\Jeff-->
<Name>default</Name>
<ViewSelectedBy>
<TypeName>Get-DockerContainer.myDockerContainer</TypeName>
</ViewSelectedBy>
<GroupBy>
@jdhitsolutions
jdhitsolutions / Get-GitSize2.ps1
Last active January 9, 2020 07:40
An enhanced revision of my Get-GitSize PowerShell function which uses type extensions for additional properties
Function Get-GitSize {
<#
.SYNOPSIS
Get the size of .git folder
.DESCRIPTION
When using git, it creates a hidden folder for change tracking. Because the file is hidden it is easy to overlook how large it might become. Specify the parent folder path. The result displays the size value in bytes but there are additional properties that show the value formatted in KB, MB or GB.
.PARAMETER Path
The path to the parent folder, not the .git folder.
.EXAMPLE
PS C:\scripts\PiedPiperBox> Get-GitSize